Initial Ubuntu Server Setup for Beginners

This tutorial will guide you on the first basic steps you need to configure on a new installed Ubuntu server in order to increase security and reliability for your server.

The configurations explained in this topic are almost the same for all Ubuntu server systems, regarding of the underlying OS platform, whether Ubuntu is installed on a bare-metal server, in a private virtual machine or a virtual machine spinned-out in a VPS public cloud.

Requirements

  1. Ubuntu Server Edition installation

Update and Upgrade Ubuntu System

The first step you need to take care of in case of fresh installation of Ubuntu server or a new deployed Ubuntu VPS is to make sure the system and all system components, such as the kernel, the package manager and all other installed packages are up-to-date with the latest released versions and security patches.

To update Ubuntu server, to log in to server’s console with an account with root privileges or directly as root and run the below commands in order to perform the update and upgrade process.

$ sudo apt update 

Update Ubuntu Server

Update Ubuntu Server

 

After running the update command, you will see the number of available packages for upgrading process and the command used for listing the packages upgrades.

$ sudo apt list --upgradable

List Upgrade Ubuntu Packages

List Upgrade Ubuntu Packages

After you’ve consulted the list of packages available for upgrading, issue the below command to start system upgrade process.

$ sudo apt upgrade

Upgrade Ubuntu Server Packages

Upgrade Ubuntu Server Packages

In order to remove all locally downloaded deb packages and all other apt-get caches, execute the below command.

$ sudo apt autoremove
$ sudo apt clean

Autoremove APT Packages and Cache

Autoremove APT Packages and Cache

Create New Account in Ubuntu

By default, as a security measure, the root account is completely disabled in Ubuntu. In order to create a new account on the system, log in to the system with the account user with root privileges and create a new account with the below command.

This new account will be granted with root powers privileges via sudo command and will be used to perform administrative tasks in the system. Make sure you setup a strong password to protect this account. Follow the adduser prompt to setup the user details and password.

$ sudo adduser ubuntu_user

Create User in Ubuntu

Create User in Ubuntu

If this account will be assigned to another system admin, you can force the user to change its password at the first log in attempt by issuing the following command.

$ sudo chage -d0 ubuntu_user

For now, the new added user cannot perform administrative tasks via sudo utility. To grant this new user account with administrative privileges you should add the user to “sudo” system group by issuing the below command.

$ sudo usermod -a -G sudo ubuntu_user

By default, all users belonging to the “sudo” group are allowed to execute commands with root privileges via sudo utility. Sudo command must be used before writing the command needed for execution, as shown in the below example.

$ sudo apt install package_name

Test if the new user has the root privileges granted, by logging in to the system and run the apt updatecommand prefixed with sudo.

$ su - ubuntu_user
$ sudo apt update

Verify New User

Verify New User

Configure System Hostname in Ubuntu

Usually, the machine hostname is set-up during the system installation process or when the VPS is created in the cloud. However, you should change the name of your machine in order to better reflect the destination of your server or to better describe its final purpose.

In a large company, machines are named after complex naming schemes in order to easily identify the machine in datacenter’s racks. For instance, if your Ubuntu machine will operate a mail server, the name of the machine should reflect this fact and you can setup machine hostname as mx01.mydomain.lan, for example.

To show details about your machine hostname run the following command.

$ hostnamectl

In order to change the name of your machine, issue hostnamectl command with the new name you will configure for your machine, as illustrated in the below excerpt.

$ sudo hostnamectl set-hostname tecmint

Verify the new name of your system with one of the below commands.

$ hostname
$ hostname -s
$ cat /etc/hostname 

Set Hostname in Ubuntu Server

Set Hostname in Ubuntu Server

Setup SSH with Public Key Authentication in Ubuntu

To increase system security degree of an Ubuntu server, you should set-up SSH public key authentication for an local account. In order to generate SSH Key Pair, the public and private key, with a specifying a key length, such as 2048 bits, execute the following command at your server console.

Make sure you’re logged in to the system with the user you’re setting up the SSH key.

$ su - ubuntu_user
$ ssh-keygen -t RSA -b 2048

Setup SSH Keys in Ubuntu

Setup SSH Keys in Ubuntu

While the key is generated, you will be prompted to add passphrase in order to secure the key. You can enter a strong passphrase or choose to leave the passphrase blank if you want to automate tasks via SSH server.

After the SSH key has been generated, you can copy the public key to a remote server by executing the below command. To install the public key to the remote SSH server you will need a remote user account with the proper permissions and credentials to log in to remote server.

$ ssh-copy-id remote_user@remote_server

Copy SSH Key to Remote Server

Copy SSH Key to Remote Server

You should be able to automatically log in via SSH to the remote server using the public key authentication method. You won’t need to add the remote user password while using SSH public key authentication.

After you’ve logged in to the remote server, you can start to execute commands, such as w command to list ssh remote logged in users, as shown in the below screenshot.

Type exit in the console to close the remote SSH session.

$ ssh remote_user@remote_server
$ w
$ exit

Verify SSH Passwordless Login

Verify SSH Passwordless Login

To see the content of your public SSH key in order to manually install the key to a remote SSH server, issue the following command.

$ cat ~/.ssh/id_rsa.pub

View SSH Key

View SSH Key

Secure SSH Server in Ubuntu

In order to secure the SSH daemon you should change the default SSH port number from 22 to a random port, higher than 1024, and disallow remote SSH access to the root account via password or key, by opening SSH server main configuration file and make the following changes.

$ sudo vi /etc/ssh/sshd_config

First, search the commented line #Port22 and add a new line underneath (replace the listening port number accordingly):

Port 2345

Don’t close the file, scroll down and search for the line #PermitRootLogin yes, uncomment the line by removing the # sign (hashtag) from the beginning of the line and modify the line to look like shown in the below excerpt.

PermitRootLogin no

Secure SSH Service

Secure SSH Service

Afterwards, restart the SSH server to apply the new settings and test the configuration by trying to log in from a remote machine to this server with the root account via the new port number. The access to root account via SSH should be restricted.

$ sudo systemctl restart sshd

Also, run netstat or ss command and filter the output via grep in order to show the new listening port number for SSH server.

$ sudo ss -tlpn| grep ssh
$ sudo netstat -tlpn| grep ssh

Verify SSH Port

Verify SSH Port

There are situations where you might want to automatically disconnect all remote SSH connections established into your server after a period of inactivity.

In order to enable this feature, execute the below command, which adds the TMOUT bash variable to your account .bashrc hidden file and forces every SSH connection made with the name of the user to be disconnected or dropped-out after 5 minutes of inactivity.

$ echo 'TMOUT=300' >> .bashrc

Run tail command to check if the variable has been correctly added at the end of .bashrc file. All subsequent SSH connections will be automatically closed after 5 minutes of inactivity from now on.

$ tail .bashrc

In the below screenshot, the remote SSH session from drupal machine to Ubuntu server via ubuntu_user account has been timed out and auto-logout after 5 minutes.

Auto Disconnect SSH Sessions

Auto Disconnect SSH Sessions

Configure Ubuntu Firewall UFW

Every server needs a well configured firewall in order to secure the system at network level. Ubuntu server uses UFW application to manage the iptables rules on the server.

Check the status of UFW firewall application in Ubuntu by issuing the below commands.

$ sudo systemctl status ufw
$ sudo ufw status

Check UFW Firewall Status

Check UFW Firewall Status

Usually, the UFW firewall daemon is up and running in Ubuntu server, but the rules are not applied by default. Before enabling UFW firewall policy in you system, first you should add a new rule to allow SSH traffic to pass through firewall via the changed SSH port. The rule can be added by executing the below command.

$ sudo ufw allow 2345/tcp

After you’ve allowed SSH traffic, you can enable and check UFW firewall application with the following commands.

$ sudo ufw enable
$ sudo ufw status

Open SSH Port and Verify

Open SSH Port and Verify

To add new firewall rules for other network services subsequently installed on your server, such as HTTP server, a mail server or other network services, use the below firewall commands examples as guide.

$ sudo ufw allow http  #allow http traffic
$ sudo ufw allow proto tcp from any to any port 25,443  # allow https and smtp traffic

To list all firewall rules run the below command.

$ sudo ufw status verbose

Check UFW Firewall Rules

Check UFW Firewall Rules

Set Ubuntu Server Time

To control or query Ubuntu server clock and other related time settings, execute timedatectl command with no argument.

In order to change your server’s time zone settings, first execute timedatectl command with list-timezones argument to list all available time zones and, then, set the time zone of your system as shown in the below excerpt.

$ sudo timedatectl 
$ sudo timedatectl list-timezones 
$ sudo timedatectl set-timezone Europe/Vienna

Set Ubuntu Timezone

Set Ubuntu Timezone

The new systemd-timesyncd systemd daemon client can be utilized in Ubuntu in order to provide an accurate time for your server across network and synchronize time with an upper time peer server.

To apply this new feature of Systemd, modify systemd-timesyncd daemon configuration file and add the closest geographically NTP servers to NTP statement line, as shown in the below file excerpt:

$ sudo nano /etc/systemd/timesyncd.conf

Add following configuration to timesyncd.conf file:

[Time]
NTP=0.pool.ntp.org 1.pool.ntp.org
FallbackNTP=ntp.ubuntu.com

NTP Time Configuration

NTP Time Configuration

To add your nearest geographically NTP servers, consult the NTP pool project server list at the following address: http://www.pool.ntp.org/en/

Afterwards, restart the Systemd timesync daemon to reflect changes and check daemon status by running the below commands. After restart, the daemon will start to sync time with the new ntp server peer.

$ sudo systemctl restart systemd-timesyncd.service 
$ sudo systemctl status systemd-timesyncd.service

Start TimeSyncd Service

Start TimeSyncd Service

Disable and Remove Unneeded Services in Ubuntu

In order to get a list of all TCP and UDP network services up-and-running by default in your Ubuntu server, execute the ss or netstat command.

$ sudo netstat -tulpn
OR
$ sudo ss -tulpn

List All Running Services

List All Running Services

Staring with Ubuntu 16.10 release, the default DNS resolver is now controlled by systemd-resolved service, as revealed by the output of netstat or ss commands.

You should also check the systemd-resolved service status by running the following command.

$ sudo systemctl status systemd-resolved.service

Check Systemd Resolved Status

Check Systemd Resolved Status

The systemd-resolved service binds on all enabled network interfaces and listens on ports 53 and 5355 TCPand UDP.

Running system-resolved caching DNS daemon on a production server can be dangerous due to the numerous number of DDOS attacks performed by malicious hackers against unsecured DNS servers.

In order to stop and disable this service, execute the following commands.

$ sudo systemctl stop systemd-resolved
$ sudo systemctl disable systemd-resolved

Disable Systemd Resolved Service

Disable Systemd Resolved Service

Verify if the service has been stopped and disabled by issuing ss or netstat command. The systemd-resolved listening ports, 53 and 5355 TCP and UDP, should not be listed in netstat or ss command output, as illustrated in the below.

You should also reboot the machine in order to completely disable all systemd-resolved daemon services and restore the default /etc/resolv.conf file.

$ sudo ss -tulpn
$ sudo netstat -tulpn
$ sudo systemctl reboot

Verify All Running Services

Verify All Running Services

Although, you’ve disabled some unwanted networking services to run in your server, there are also other services installed and running in your system, such as lxc process and snapd service. These services can be easily detected via pstop or pstree commands.

$ sudo ps aux
$ sudo top
$ sudo pstree

List Running Services in Tree Format

List Running Services in Tree Format

In case you’re not going to use LXC container virtualization in your server or start installing software packaged via Snap package manager, you should completely disable and remove these services, by issuing the below commands.

$ sudo apt autoremove --purge lxc-common lxcfs
$ sudo apt autoremove --purge snapd

That’s all! Now, Ubuntu server is now prepared for installing additional software needed for custom network services or applications, such as installing and configuring a web server, a database server, a file share service or other specific applications.

Source

Installation of Ubuntu 16.04 Server Edition (classics retro)

Ubuntu Server 16.04, also named Xenial Xerus, has been released by Canonical and it’s now ready for installation.

The details about this new LTS version can be found on the previous article: How to upgrade Ubuntu 15.10 to 16.04.

This topic will guide you on how you can install Ubuntu 16.04 Server Edition with Long Time Support on your machine.

If you’re looking for Desktop Edition, read our previous article: Installation of Ubuntu 16.04 Desktop

Requirements

  1. Ubuntu 16.04 Server ISO Image

Install Ubuntu 16.04 Server Edition

1. On the first step visit the above link and download the latest version of Ubuntu Server ISO image on your computer.

Once the image download completes, burn it to a CD or create a bootable USB disk using Unbootin (for BIOS machines) or Rufus (for UEFI machines).

2. Place the bootable media intro the appropriate drive, start-up the machine and instruct the BIOS/UEFI by pressing a special function key (F2F11F12) to boot-up from the inserted USB/CD drive.

In a few seconds you will be presented with the first screen of Ubuntu installer. Select your language to perform the installation and hit Enter key to move to the next screen.

Choose Ubuntu 16.04 Server Installation Language

Choose Ubuntu 16.04 Server Installation Language

3. Next, select the first option, Install Ubuntu Server and press Enter key to continue.

Install Ubuntu 16.04 Server

Install Ubuntu 16.04 Server

4. Select the language you with to install the system and press Enter again to continue further.

Select Language for Ubuntu 16.04 Server

Select Language for Ubuntu 16.04 Server

5. On the next series of screen choose your physical location from the presented list. If your location is different than the ones offered on the first screen, select other and hit Enter key, then select the location based on your continent and country. This location will be also used by the timezone system variable. Use the below screenshots as a guide.

Choose Location for Ubuntu 16.04 Server

Choose Location for Ubuntu 16.04 Server

Select Country Region

Select Country Region

Select Area Location

Select Area Location

6. Assign the locales and keyboard settings for your system as illustrated below and hit Enter to continue the installation setup.

Configure Locales

Configure Locales

Configure Keyboard Layout

Configure Keyboard Layout

7. The installer will load a series of additional components required for the next steps and will automatically configure your network settings in case you have a DHCP server on the LAN.

Because this installation is intended for a server it’s a good idea to setup a static IP address for your network interface.

To do this you can interrupt the automatic network configuration process by pressing on Cancel or once the installer reaches hostname phase you can hit on Go Back and choose to Configure network manually.

Set Ubuntu 16.04 Hostname

Set Ubuntu 16.04 Hostname

Configure Network Manually

Configure Network Manually

8. Enter your network settings accordingly (IP Address, netmask, gateway and at least two DNS nameservers) as illustrated on the below images.

Set Static IP Address on Ubuntu 16.04

Set Static IP Address on Ubuntu 16.04

Configure Network Mask for Ubuntu 16.04

Configure Network Mask for Ubuntu 16.04

Configure Network Gateway for Ubuntu 16.04

Configure Network Gateway for Ubuntu 16.04

Configure Network DNS on Ubuntu 16.04

Configure Network DNS on Ubuntu 16.04

9. On the next step setup a descriptive hostname for your machine and a domain (not necessary required) and hit on Continue to move to the next screen. This step concludes the network settings.

Set Ubuntu 16.04 Server Hostname

Set Ubuntu 16.04 Server Hostname

Set Ubuntu 16.04 Domain Name

Set Ubuntu 16.04 Domain Name

 

10. On this step the installer prompts you to setup a username and a password for your system. This username will be granted by the system with sudo powers, so, technically, this user will be the supreme administrator next to root account (which is disabled by default).

Thus, choose an inspired username, maybe hard to guess for security reasons, with a strong password and hit on Continue. Choose not to encrypt your home directory and press Enter to continue further.

Setup User and Password

Setup User and Password

11. Next, the installer will automatically set your clock based on the physical location configured earlier. In case the location is correctly chosen hit on Yes to continue to disk partition layout.

Configure System Clock

Configure System Clock

12. On the next step you can choose the method that will be used to slice up your disk. For instance, if you need to create custom partition scheme (such as /home/var/boot etc) choose Manual method.

For a general purpose server you can stick to Guided with LVM method as illustrated below, which automatically creates the partitions on your behalf.

Select Partition Method

Select Partition Method

13. Next, select the disk that will be used by the installer to create partitions and press Enter key.

Select Disk Partition

Select Disk Partition

14. Answer with Yes at the next screen in order to commit changes to disk with LVM scheme and hit on Continue to use the entire disk space for guided partitions.

Add Disk Partition Size

Add Disk Partition Size

Confirm Disk Partition Changes

Confirm Disk Partition Changes

15. Finally, approve for the last time the changes to be written to disk by pressing on Yes and the installation will now begin. From this step on all the changes will be committed to disk.

Confirm Disk Partition Changes

Confirm Disk Partition Changes

Installing Ubuntu 16.04 Server

Installing Ubuntu 16.04 Server

16. In case your system is behind a proxy or a firewall use the next screen to bypass the network restrictions, otherwise just leave it black and hit on Continue.

Configure System Package Manager

Configure System Package Manager

17. Next, the installer will configure apt repositories and will install the selected software. After it finishes the installation tasks a new screen will appear which will ask you how to manage the upgrade process. Select Noautomatic updates for now (you will manually select what updates are necessary) and hit Enter key to continue.

Manage Ubuntu 16.04 Upgrades

Manage Ubuntu 16.04 Upgrades

18. On the next step you will be asked to select what software to install. Select only standard system utilities and OpenSSH server (if you require remote access) by pressing the spacebar key and hit on Continue.

System Software Selection

System Software Selection

19. Once the installer finishes installing the software, a new screen will prompt you whether to install the Grubboot loader to hard disk MBR (first 512 byte sector). Obviously without the GRUB you can’t boot up your system after restart, so hit on Yes to continue with the installation.

Install Grub Boot Loader

Install Grub Boot Loader

20. Finally, after the boot loader is written to Hard Disk MBR, the installation process finishes. Hit on Continue to reboot the machine and remove the installation media.

Finish Ubuntu 16.04 Server Installation

Finish Ubuntu 16.04 Server Installation

21. After reboot, login to your system console using the credentials configured during the installation process and you’re good to go on production with your server.

Ubuntu 16.04 Server Login Prompt

Ubuntu 16.04 Server Login Prompt

That’s all! Keep in mind that this version of Ubuntu has official maintenance support from Canonical until 2021for hardware, bugs, software and security updates.

Source

How to Upgrade to Ubuntu 18.04 Bionic Beaver

Ubuntu 18.04 LTS (codenamed “Bionic Beaver”) stable version has been released. It will be supported for 5 years until April 2023.

In this article, we will explain how to upgrade to Ubuntu 18.04 Bionic Beaver from Ubuntu 16.04 LTS or 17.10.

What’s New in Ubuntu 18.04

Before we proceed to the upgrade instructions, let’s look at some of the base system new features and changes in 18.04:

  • Ships in with Linux kernel 4.15.
  • OpenJDK 10 is the default JRE/JDK.
  • Gcc is now set to default to compile applications.
  • The default CIFS/SMB protocol version change in CIFS mounts.
  • Supports mitigations to protect against Spectre and Meltdown.
  • Bolt and thunderbolt-tools have been promoted to main.
  • Libteam which is available in the Network manager, offers teaming support.
  • Systemd-resolved is the default resolver.
  • ifupdown has been deprecated in favor of netplan.io, in new installs.
  • networkctl command can be used to view a summary of network devices.
  • GPG binary is provided by gnupg2.
  • Swap file will be used by default instead of a swap partition, in new installs.
  • Python 2 is no longer comes preinstalled, and Python 3 has been updated to 3.6.
  • For new installs, the installer no longer offers the encrypted home option using ecryptfs-utils.
  • OpenSSH no longer uses RSA keys smaller than 1024 bits and much more under desktop and server versions.

Warning: Start by backing up your existing Ubuntu installation or important files (documents, images and many more), before performing an upgrade. This is recommended because, sometimes, upgrades do not go well as planned.

A backup will ensure that your data remains intact, and you can recover it, in case of any failures during the upgrade process, that could lead to data loss.

Upgrade to Ubuntu 18.04 Desktop

1. First of all, ensure that your existing Ubuntu system is up-to-date, otherwise run the commands below to update the apt package source cache and perform an upgrade of installed packages, to the latest versions.

$ sudo apt update
$ sudo apt upgrade 

Then, restart your system to finish installing the updates.

2. Next, launch the “Software & Updates” application from System Settings.

Ubuntu Software and Updates

Ubuntu Software and Updates

3. Then click on the third Tab “Updates”.

Select Updates

Select Updates

4. Next, On Ubuntu 17.04, set the “Notify me of a new Ubuntu version” dropdown menu to “For any new version”. You will be asked to authenticate, enter your password to continue. On Ubuntu 16.04, leave this setting to “For long-term support versions”.

Notify New Ubuntu Version

Notify New Ubuntu Version

5. Then search for “Software Updater” and launch it or open a terminal and run the update-manager command as shown.

$ update-manager -cd 

The update manager should open up and inform you like this: New distribution release ‘18.04’ is available.

Run Update Manager

Run Update Manager

6. Next, click on “Upgrade” and enter your password to continue. Then you will be shown the Ubuntu 18.04release notes page. Read through it and click Upgrade.

Upgrade to Ubuntu 18.04

Upgrade to Ubuntu 18.04

7. Now your upgrade process will start as shown in the following screenshot.

Ubuntu Upgrade Process

Ubuntu Upgrade Process

8. Read the details of the upgrade and confirm that you want to upgrade by clicking on “Start Upgrade”.

Start Ubuntu Upgrade

Start Ubuntu Upgrade

9. Once you have confirmed that you want the upgrade, the update manager will start downloading Ubuntu 18.04 packages as shown in the following screenshot. When all packages have been retrieved, the process can not be canceled. You can click on “Terminal” to see how the upgrade process is unfolding.

Downloading Ubuntu 18.04 Packages

Downloading Ubuntu 18.04 Packages

10. Afterwards, all the Ubuntu 18.04 packages will be installed on the system (this will take some time), then you will be asked to either remove or keep obsolete packages. After clean up and restart the system to complete the upgrade.

Restart Ubuntu to Complete Upgrade

Restart Ubuntu to Complete Upgrade

11. Then, you can login and start using Ubuntu 18.04 LTS.

Ubuntu 18.04 Login

Ubuntu 18.04 Login

Ubuntu 18.04 Desktop

Ubuntu 18.04 Desktop

Ubuntu 18.04 Summary

Ubuntu 18.04 Summary

Upgrade to Ubuntu 18.04 Server

If you do not have physical access to your server, the upgrade can be performed over SSH, though this method has one major limitation; in case of loss of connectivity, it is harder to recover. However, the GNU screen program is used to automatically re-attach in case of dropped connection problems.

1. Begin by installing the update-manager-core package, if it is not already installed as shown.

$ sudo apt install update-manager-core

2. Next, ensure that the prompt line in /etc/update-manager/release-upgrades is set to normal. If that is the case, launch the upgrade tool with the following command.

$ sudo do-release-upgrade 

3. Then follow the on-screen instructions to continue.

You can find more information, especially concerning changes in desktop and server releases, from the Ubuntu 18.04 release notes page.

Source

Ubuntu 16.04 LTS (Xenial Xerus) Installation Guide (classics retro).

A little too early, not too late.

Here, we already have a guided installation procedure on the next iteration of the world’s most popular free operating system — Ubuntu 16.04 LTS.

Canonical currently released the first beta images of Ubuntu 16.04; however, there’s no standard Unity flavor at this time and sadly, we won’t be seeing it until the 24th of March – which is the release date for beta 2 — and we should see stable builds emerging in by April 21st — followed by subsequent release candidates.

If you’re worried on how this guide will work with the first point release, worry no more as the installation procedure hasn’t changed so much from the previous releases so if you are familiar with the installation of previously released Ubuntu versions, then you shouldn’t find it too hard breezing through with this one.

Ubuntu 16.04 Xenial Xerus is now official and you can download either the 32bit or 64bit ISO images from herebeforehand.

Once you’ve done that, you may now continue with the installation procedure which is absolutely straight forward; however, if you do run into problems, you can always leave a comment down below.

We also covered on how you can dual boot Ubuntu 16.04 with your current windows 10 or 8 system even though we have a previous guide on that subject here – just call this an updated version.

If you’re looking for Server Edition installation, read our article: Installation of Ubuntu 16.04 Server

As you’re probably familiar with, the installation of multiple OSes in a dual/triple boot configuration requires a bit of technical expertise from your end – as you might have to go into your BIOS or UEFI (on newer systems) to do some manual configuration but that shouldn’t be too difficult.

For systems with legacy BIOS, all you’ll need to do is change the boot order and depending on your system, you might have to press the F2F10F12DEL key to enter your BIOS (you might need to Google your way around that) – while on the latter i.e UEFI, you’d mostly need to disable secure boot and fast boot and enable legacy support — that is, if the OS you’re trying to install doesn’t have UEFI support baked in by default – but, such isn’t the case of Ubuntu Xenial Xerus 16.04 LTS.

Ubuntu 16.04 LTS comes with UEFI support and it should install just fine on your PC – be it in a dual boot fashion or a single install.

As usual, pre-requisites, we must get.

Ubuntu is currently only available as an alpha install and you can proceed and download the most recent daily build image from here.

We’d assume you’ve downloaded the latest stable build from the official Ubuntu mirrors as provided in the links above.

Once, you have your ISO image ready, you may now proceed to creating a bootable disk with Rufus, or universal USB installer. You’d mostly want to go with the former as it’s as straight forward as (making an installable USB) can get – moving forward, get your PC set (plug it in), make sure you’re connected to the internet and you’re good to go.

Note: Given the time at which this article was originally published, the standard Ubuntu flavor is only available in alpha; however, we’ll be update this guide (if needed) once the beta 2 image is available for download and the stable release too.

At this point, we’ve updated the article as promised so you may proceed with full confidence in the procedure.

The curated list of features to be expected with the final build of Ubuntu include:

  1. First Ubuntu LTS to ship Systemd as the default service manager.
  2. Mir display server.
  3. Ubuntu 16.04 will ship in two variants, one with Unity 7 and another with Unity 8. With the latter expected to become standard after the release of 16.10.
  4. Unity launcher position change (to whatever side of the screen you want to place it).
  5. The server filesystem ZFS will also be implemented in the next LTS release.
  6. Linux kernel 4.4 will ship with 16.04 LTS.
  7. Considering it being an LTS release, you’ll also get 5 years ongoing software support.
  8. Gnome software center to replace Ubuntu’s archaic software center experience.
  9. The Ubuntu devs also hope to implement Snappy have implemented Snappy with Unity 7 which is the GUI of Xenial Xerus. however, it’s unlikely that it will be ready be the time Xenial Xerus will be making its way to the market by April.
  10. Firmware updates via the Gnome software center is also a possibility.
  11. After being severely bashed by privacy advocates, Ubuntu 16.04 LTS will finally turned off by default, the controversial online search (that gathers search results from the likes of Wikipedia and Amazon when you launch the dash to search for something locally stored on your PC). It’s now turned off by default.

Ubuntu Settings Privacy Change

Ubuntu Settings Privacy Change

Once we have all that cleared up, you may now proceed.

Ubuntu 16.04 Installation Guide

1. First off, plug in your USB drive into the intended install PC after which you’ll power the said system up and boot from USB disk (provided you’ve done the needed BIOS or UEFI configuration as mentioned above).

And you are greeted with what may seem a familiar screen – depending on how much time you’ve had with Ubuntu and derivatives in the past. Well, you want to proceed by clicking the install Ubuntu button but if you’d rather give the system a spin first, then go ahead and select the first option (try Ubuntu).

Ubuntu 16.04 Installation

Ubuntu 16.04 Installation

When you now decide to proceed with the installation, you’ll get a dissimilar welcome screen – thereafter, everything is pretty much the same if you decide to NOT try the OS first.

As you can see on the left bar of both screenshots, you’ll have to choose your language as needed; and this, of course, will be the default (once installed) throughout the system.

2. Next up is your preparation screen and you should tick both options before you continue so you won’t have to go through the hassle of installing updates and codecs after you might have completed the installation. If you are without an internet connection though, the first option will be greyed out, but then you can tick the second and continue your installation.

Preparing to Install Ubuntu 16.04

Preparing to Install Ubuntu 16.04

3. At this point, you have to choose your installation type and the first screenshot is an automated process, even if you have an operating system already installed, the installer will auto-detect it and allow you partition the drive in the next screen with simple sliders that will auto-allocate your assigned space for the Ubuntu partition.

Choose an option as needed and proceed – you may also decide to encrypt your disk or use (LVM) logical volume manager with your Ubuntu installation – but we advise that you select those ONLY if you know what you’re doing.

If you’d prefer to manually partition your disk though for Ubuntu 16.04 dual boot with Windows, go to the end of the article at section Ubuntu 16.04 Manual Partitioning and come back to #5 to continue with the installation.

Select Ubuntu 16.04 Installation Type

Select Ubuntu 16.04 Installation Type

4. Prompt to confirm that you want the changes to be made to your internal drive; click continue to move onto the next screen.

Write Changes to Disk

Write Changes to Disk

5. This is where you select your current location; hint: the setup auto-detects your location if you’re connected to the internet.

Select Current Location

Select Current Location

6. Configure as needed — depending on your type of keyboard and default input language.

Select Keyboard Layout

Select Keyboard Layout

7. This is where you enter your user details in the right order – that is, descending; after which you can click continue to proceed to the next screen.

Create User Account

Create User Account

8. Right up next, is the beginning of installation which (depending on your PC hardware), can take a long or short time.

Ubuntu 16.04 Installation Process

Ubuntu 16.04 Installation Process

9. At this point, the installation is complete and now, you may restart your PC.

Ubuntu 16.04 Installation Complete

Ubuntu 16.04 Installation Complete

10. Once you’ve restarted, you are now greeted with the login screen where you input your password (or in the case of multiple users select your name) and press enter to continue to the Unity7/8 DE.

Ubuntu 16.04 Login Screen

Ubuntu 16.04 Login Screen

11. Ubuntu 16.04 desktop.

Ubuntu 16.04 Desktop Loading

Ubuntu 16.04 Desktop Loading

Ubuntu 16.04 Desktop with Applications

Ubuntu 16.04 Desktop with Applications

Update Ubuntu 16.04

12. A good practice for any Linux user is to update the system once it’s done installing – hence, a brief how-to-update walkthrough.

First off, go on to the Unity dash (which is the square button on the top left corner in the image above and below) and search for “software and updates”, open it and select the “other sources” tab, tick both options (mind you, you’ll be prompted to enter your root password) the software cache is updated and you’re good to go.

Ubuntu 16.04 Software and Updates

Ubuntu 16.04 Software and Updates

Ubuntu 16.04 Other Software Sources

Ubuntu 16.04 Other Software Sources

Ubuntu 16.04 Updating Cache

Ubuntu 16.04 Updating Cache

Once you have that setup, you may not go to the same dash and type in “terminal” and enter the follow-up commands (consecutively) to update your Ubuntu installation.

$ sudo apt-get update
$ sudo apt-get upgrade

Ubuntu 16.04 Update

Ubuntu 16.04 Update

Ubuntu 16.04 Upgrade

Ubuntu 16.04 Upgrade

13. The new gnome app store in Ubuntu is perhaps the most prominent feature of the OS and as of this writing, it doesn’t exactly seem to function as expected, however, considering the alpha status of the image I’m using, such things are expected and most issues and whatnot should be ironed out before the “stable” is ready for prime-time in April.

Ubuntu 16.04 Gnome Software Center

Ubuntu 16.04 Gnome Software Center

Ubuntu 16.04 Manual Partitioning

Manual partitioning — #3 for those of you that will rather take this route.

3a. Instead of “Erase disk and install Ubuntu”, go ahead and choose the last option “something else”.

Ubuntu 16.04 Manual Partitioning

Ubuntu 16.04 Manual Partitioning

3b. Depending on the number of physical drives you have hooked up in your PC, they can be labelled as dev/sdadev/sdbdev/sdc and so on. In my case, however, I’ve only got one HD to install Ubuntu in – dev/sda.

Ubuntu 16.04 Select Installation Partition

Ubuntu 16.04 Select Installation Partition

3c. Now you may go on and create a partition table.

Create New Partition Table for Ubuntu 16.04

Create New Partition Table for Ubuntu 16.04

3d. After you might have done that, you want to proceed and create the partitions you’ll need for Ubuntu (by clicking the + button in the lower area of the partition screen); if you’re on a low specced PC with say, 2GB of RAM, it’s advisable to create a minimum swap partition (equivalent of virtual memory on Windows) that is twice the size of the physical memory. In my case, I have 2GB of RAM so I created a swap partition of 4GB.

Create Swap Partition for Ubuntu 16.04

Create Swap Partition for Ubuntu 16.04

In the case where your PC has 8GB (or more) of physical memory, it is rather irrelevant to create a swap space of twice that amount (cause you’ll never get to use even half of it) so it only makes sense to create something not too big – something like 2GB will be just okay.

3e. Once you’re done creating your swap, you can now go ahead and create a root partition with the rest of the free space available. However, if you’d prefer a separate partition for your home folder, you can as well create it, but you’re mostly fine with a single partition.

Create Root Partition for Ubuntu 16.04

Create Root Partition for Ubuntu 16.04

3f. From the screenshot below, my swap is labelled “/dev/sda1 swap” and my root partition is “/dev/sda2 /”.

Ubuntu 16.04 Custom Partition Table

Ubuntu 16.04 Custom Partition Table

3g. lastly, confirm that you want to write the changes to disk and go back to #5 to continue your installation.

Confirm Ubuntu 16.04 Partition Changes

Confirm Ubuntu 16.04 Partition Changes

If you encounter any difficulty while installing, let us know in the comments below and we’ll respond as quickly as we can.

Source

How to Install and Run VLC Media Player as Root in Linux

VLC is a free and open source cross-platform multimedia player, encoder and streamer that works. It is a very popular (and possibly the most used) media player out there.

Some of its notable features include support for almost all (if not most) multimedia files, it also supports Audio CDs, VCDs, and DVDs. Additionally, VLC supports various streaming protocols enabling users to stream content over a network.

Suggested Read: 10 Best Open Source Media Players for Linux

In this article, we will show you a simple hack that will enable you to run VLC media player as root user in Linux.

Note: There is a reason why VLC won’t run in a root account (or can’t be run as root), so because the root account is for system maintenance only, not for everyday activities.

Install VLC Player in Linux

Installing VLC is so easy, it is available in official repositories of mainstream Linux distros, just run the following command on your respective Linux distribution.

$ sudo apt install vlc   	 #Debain/Ubuntu
$ sudo yum install vlc 	         #RHEL/CentOS
$ sudo dnf install vlc   	 #Fedora 22+

If you are running your Linux system as root, for example Kali Linux, you’ll get the error below when you try to run VLC.

"VLC is not supposed to be run as root. Sorry. If you need to use real-time priorities and/or privileged TCP ports you can use vlc-wrapper (make sure it is Set-UID root and cannot be run by non-trusted users first)."

Alternative Ways to Run VLC as Root User

Run the sed command below to make changes in the VLC binary file, it will replace the geteuid variable (which determines the effective user ID of the calling process) with getppid (which will determine the parent process ID of the calling process).

In this command, ‘s/geteuid/getppid/‘ (regexp=geteuid, replacement=getppid) does the magic.

$ sudo sed -i 's/geteuid/getppid/' /usr/bin/vlc

Alternatively, edit the VLC binary file using a hex-editor such as blesshexeditor. Then search for geteuid string and replace it with getppid, save the file and exit.

Yet again, another way around this is to download and compile the VLC source code by passing the --enable-run-as-root flag to ./configure and VLC should be able to run as root.

That’s all! You should now run VLC as root user in Linux. To share any thoughts, use the feedback form below.

Source

How to Setup High-Availability Load Balancer with ‘HAProxy’ to Control Web Server Traffic

HAProxy stands for High Availability proxy. It is a Free and open source application written in C programming Language. HAProxy application is used as TCP/HTTP Load Balancer and for proxy Solutions. The most common use of the HAProxy application is to distribute the workload across multiple servers e.g., web server, database server, etc thus improving the overall performance and reliability of server environment.

The highly efficient and fast application is used by many of the world’s reputed organization which includes but not limited to – Twitter, Reddit, GitHub and Amazon. It is available for Linux, BSD, Solaris and AIX platform.

Install HAProxy in Linux

Install HAProxy Load Balancer in Linux

In this tutorial, we will discuss the process of setting up a high availability load balancer using HAProxy to control the traffic of HTTP-based applications (web servers) by separating requests across multiple servers.

For this article, we’re using the most recent stable release of HAProxy version i.e. 1.5.10 released on December 31st 2014. And also we’re using CentOS 6.5 for this setup, but the below given instructions also works on CentOS/RHEL/Fedora and Ubuntu/Debian distributions.

My Environment Setup

Here our load-balancer HAProxy server having hostname as websrv.tecmintlocal.com with IP address 192.168.0.125.

HAProxy Server Setup
Operating System	:	CentOS 6.5
IP Address		: 	192.168.0.125
Hostname		: 	websrv.tecmintlocal.com
Client Web Servers Setup

The other four machines are up and running with web servers such as Apache.

Web Server #1 :	CentOS 6.5 [IP: 192.168.0.121] - [hostname: web1srv.tecmintlocal.com]
Web Server #2 :	CentOS 6.5 [IP: 192.168.0.122] - [hostname: web2srv.tecmintlocal.com]
Web Server #3 :	CentOS 6.5 [IP: 192.168.0.123] - [hostname: web3srv.tecmintlocal.com]
Web Server #4 :	CentOS 6.5 [IP: 192.168.0.124] - [hostname: web4srv.tecmintlocal.com]

Step 1: Installing Apache on Client Machines

1. First we have to install Apache in all four server’s and share any one of site, for installing Apache in all four server’s here we going to use following command.

# yum install httpd		[On RedHat based Systems]
# apt-get install apache2	[On Debian based Systems]

2. After installing Apache web server on all four client machines, you can verify anyone of the server whether Apache is running by accessing it via IP address in browser.

http://192.168.0.121

Check Apache Status

Check Apache Status

Step 2: Installing HAProxy Server

3. In most of the today’s modern Linux distributions, HAPRoxy can be easily installed from the default base repository using default package manager yum or apt-get.

For example, to install HAProxy on RHEL/CentOS/Fedora and Debian/Ubuntu versions, run the following command. Here I’ve included openssl package too, because we’re going to setup HAProxy with SSL and NON-SSL support.

# yum install haproxy openssl-devel	[On RedHat based Systems]
# apt-get install haproxy		[On Debian based Systems]

Note: On Debian Whezzy 7.0, we need to enable the backports repository by adding a new file backports.listunder “/etc/apt/sources.list.d/” directory with the following content.

# echo "deb http://cdn.debian.net/debian wheezy-backports main" >> /etc/apt/sources.list.d/backports.list

Next, update the repository database and install HAProxy.

# apt-get update
# apt-get install haproxy -t wheezy-backports

Step 3: Configure HAProxy Logs

4. Next, we need to enable logging feature in HAProxy for future debugging. Open the main HAProxy configuration file ‘/etc/haproxy/haproxy.cfg‘ with your choice of editor.

# vim /etc/haproxy/haproxy.cfg

Next, follow the distro-specific instructions to configure logging feature in HAProxy.

On RHEL/CentOS/Fedora

Under #Global settings, enable the following line.

log         127.0.0.1 local2
On Ubuntu/Debian

Under #Global settings, replace the following lines,

log /dev/log        local0
log /dev/log        local1 notice 

With,

log         127.0.0.1 local2

Enable HAProxy Logging

Enable HAProxy Logging

5. Next, we need to enable UDP syslog reception in ‘/etc/rsyslog.conf‘ configuration file to separate log files for HAProxy under /var/log directory. Open your your ‘rsyslog.conf‘ file with your choice of editor.

# vim /etc/rsyslog.conf

Uncommnet ModLoad and UDPServerRun, Here our Server will listen to Port 514 to collect the logs into syslog.

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

Configure HAProxy Logging

Configure HAProxy Logging

6. Next, we need to create a separate file ‘haproxy.conf‘ under ‘/etc/rsyslog.d/‘ directory to configure separate log files.

# vim /etc/rsyslog.d/haproxy.conf

Append following line to the newly create file.

local2.*	/var/log/haproxy.log

HAProxy Logs

HAProxy Logs

Finally, restart the rsyslog service to update the new changes.

# service rsyslog restart

Step 4: Configuring HAProxy Global Settings

7. Now, here we need to set default variables in ‘/etc/haproxy/haproxy.cfg‘ for HAProxy. The changes needs to make for default under default section as follows, Here some of the changes like timeout for queue, connect, client, server and max connections need to be defined.

In this case, I suggest you to go through the HAProxy man pages and tweak it as per your requirements.

#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    20
    timeout queue           86400
    timeout connect         86400
    timeout client          86400
    timeout server          86400
    timeout http-keep-alive 30
    timeout check           20
    maxconn                 50000

HAProxy Default Settings

HAProxy Default Settings

8. Then we need to define front-end and back-end as shown below for Balancer in ‘/etc/haproxy/haproxy.cfg‘ global configuration file. Make sure to replace the IP addresses, hostnames and HAProxy login credentials as per your requirements.

frontend LB
   bind 192.168.0.125:80
   reqadd X-Forwarded-Proto:\ http
   default_backend LB

backend LB 192.168.0.125:80
   mode http
   stats enable
   stats hide-version
   stats uri /stats
   stats realm Haproxy\ Statistics
   stats auth haproxy:redhat		# Credentials for HAProxy Statistic report page.
   balance roundrobin			# Load balancing will work in round-robin process.
   option httpchk
   option  httpclose
   option forwardfor
   cookie LB insert
   server web1-srv 192.168.0.121:80 cookie web1-srv check		# backend server.
   server web2-srv 192.168.0.122:80 cookie web2-srv check		# backend server.
   server web3-srv 192.168.0.123:80 cookie web3-srv check		# backend server.
   server web4-srv 192.168.0.124:80 check backup			# backup fail-over Server, If three of the above fails this will be activated.

HAProxy Global Configuration

HAProxy Global Configuration

9. After adding above settings, our load balancer can be accessed at ‘http://192.168.0.125/stats‘ with HTTP authentication using login name as ‘haproxy‘ and password ‘redhat‘ as mentioned in the above settings, but you can replace them with your own credentials.

10. After you’ve done with the configuration, make sure to restrat the HAProxy and make it persistent at system startup on RedHat based systems.

# service haproxy restart
# chkconfig haproxy on
# chkconfig --list haproxy

Start HAProxy

Start HAProxy

For Ubuntu/Debian users to need to set “ENABLED” option to “1” in ‘/etc/default/haproxy‘ file.

ENABLED=1

Step 5: Verify HAProxy Load Balancer

11. Now it’s time to access our Load balancer URL/IP and verify for the site whether loading. Let me put one HTML file in all four servers. Create a file index.html in all four servers in web servers document root directory and add the following content to it.

<html>
<head>
  <title>Tecmint HAProxy Test Page</title>
</head>

<body>
<!-- Main content -->
<h1>My HAProxy Test Page</h1>

<p>Welcome to HA Proxy test page!

<p>There should be more here, but I don't know
what to be write :p.

<address>Made 11 January 2015<br>
  by Babin Lonston.</address>

</body>
</html>

12. After creating ‘index.html‘ file, now try to access the site and see whether I can able access the copied html file.

http://192.168.0.125/

Verify HAProxy Load Balancer

Verify HAProxy Load Balancer

Site has been successfully accessed.

Step 6: Verify Statistic of Load Balancer

13. To get the statistic page of HAProxy, you can use the following link. While asking for Username and password we have to provide the haproxy/redhat.

http://192.168.0.125/stats

HAProxy Statistics Login

HAProxy Statistics Login

HAProxy Statistics

HAProxy Statistics

Step 7: Enabling SSL in HAProxy

14. To enable SSL in HAProxy, you need to install mod_ssl package for creating SSL Certificate for HAProxy.

On RHEL/CentOS/Fedora

To install mod_ssl run the following command

# yum install mod_ssl -y

On Ubuntu/Debian

By default under Ubuntu/Debian SSL support comes standard with Apache package. We just need to enable it..

# a2enmod ssl

After you’ve enabled SSL, restart the Apache server for the change to be recognized.

# service apache2 restart

15. After restarting, Navigate to the SSL directory and create SSL certificate using following commands.

# cd /etc/ssl/
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/tecmint.key -out /etc/ssl/tecmint.crt
# cat tecmint.crt tecmint.key > tecmint.pem

Create SSL for HAProxy

Create SSL for HAProxy

SSL Certificate for HAProxy

SSL Certificate for HAProxy

16. Open and edit the haproxy configuration and add the SSL front-end as below.

# vim /etc/haproxy/haproxy.cfg 

Add the following configuration as frontend.

frontend LBS
   bind 192.168.0.125:443 ssl crt /etc/ssl/tecmint.pem
   reqadd X-Forwarded-Proto:\ https
   default_backend LB

17. Next, add the redirect rule in backend configuration.

redirect scheme https if !{ ssl_fc }

Enable SSL on HAProxy

Enable SSL on HAProxy

18. After making above changes, make sure to restart the haproxy service.

# service haproxy restart

While restarting if we get the below warning, we can fix it by adding a parameter in Global Section of  haproxy.

SSL HAProxy Error

SSL HAProxy Error

tune.ssl.default-dh-param 2048

19. After restarting, try to access the site 192.168.0.125, Now it will forward to https.

http://192.168.0.25

Verify SSL HAProxy

Verify SSL HAProxy

SSL Enabled HAProxy

SSL Enabled HAProxy

20. Next, verify the haproxy.log under ‘/var/log/‘ directory.

# tail -f /var/log/haproxy.log

Check HAProxy Logs

Check HAProxy Logs

Step 8: Open HAProxy Ports on Firewall

21. Open the port’s for web service and Log reception UDP port using below rules.

On CentOS/RHEL 6
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 514 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
On CentOS/RHEL 7 and Fedora 21
# firewall­cmd ­­permanent ­­zone=public ­­add­port=514/tcp
# firewall­cmd ­­permanent ­­zone=public ­­add­port=80/tcp
# firewall­cmd ­­permanent ­­zone=public ­­add­port=443/tcp
# firewall­cmd ­­reload 
On Debian/Ubuntu

Add the following line to ‘/etc/iptables.up.rules‘ to enable ports on firewall.

A INPUT ­p tcp ­­dport 514 ­j ACCEPT 
A INPUT ­p tcp ­­dport 80 ­j ACCEPT 
A INPUT ­p tcp ­­dport 443 ­j ACCEPT 

Conclusion

In this article, we’ve installed Apache in 4 server’s and shared a website for reducing the traffic load. I Hope this article will help you to setup a Load Balancer for web server’s using HAProxy and make your applications more stable and available

If you have any questions regarding the article, feel free to post your comments or suggestions, I will love to help you out in whatever the best way I can.

Source

How to Check Which Apache Modules are Enabled/Loaded in Linux

In this guide, we will briefly talk about the Apache web server front-end and how to list or check which Apache modules have been enabled on your server.

Apache is built, based on the principle of modularity, this way, it enables web server administrators to add different modules to extend its primary functionalities and enhance apache performance as well.

Suggested Read: 5 Tips to Boost the Performance of Your Apache Web Server

Some of the common Apache modules include:

  1. mod_ssl – which offers HTTPS for Apache.
  2. mod_rewrite – which allows for matching url patterns with regular expressions, and perform a transparent redirect using .htaccess tricks, or apply a HTTP status code response.
  3. mod_security – which offers you to protect Apache against Brute Force or DDoS attacks.
  4. mod_status – that allows you to monitor Apache web server load and page statics.

In Linux, the apachectl or apache2ctl command is used to control Apache HTTP server interface, it is a front-end to Apache.

You can display the usage information for apache2ctl as below:

$ apache2ctl help
OR
$ apachectl help
apachectl help
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
  -D name            : define a name for use in  directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)
  -S                 : a synonym for -t -D DUMP_VHOSTS
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files

apache2ctl can function in two possible modes, a Sys V init mode and pass-through mode. In the SysV initmode, apache2ctl takes simple, one-word commands in the form below:

$ apachectl command
OR
$ apache2ctl command

For instance, to start Apache and check its status, run these two commands with root user privileges by employing the sudo command, in case you are a normal user:

$ sudo apache2ctl start
$ sudo apache2ctl status
Check Apache Status
tecmint@TecMint ~ $ sudo apache2ctl start
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
httpd (pid 1456) already running
tecmint@TecMint ~ $ sudo apache2ctl status
Apache Server Status for localhost (via 127.0.0.1)

Server Version: Apache/2.4.18 (Ubuntu)
Server MPM: prefork
Server Built: 2016-07-14T12:32:26

-------------------------------------------------------------------------------

Current Time: Tuesday, 15-Nov-2016 11:47:28 IST
Restart Time: Tuesday, 15-Nov-2016 10:21:46 IST
Parent Server Config. Generation: 2
Parent Server MPM Generation: 1
Server uptime: 1 hour 25 minutes 41 seconds
Server load: 0.97 0.94 0.77
Total accesses: 2 - Total Traffic: 3 kB
CPU Usage: u0 s0 cu0 cs0
.000389 requests/sec - 0 B/second - 1536 B/request
1 requests currently being processed, 4 idle workers

__W__...........................................................
................................................................
......................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

And when operating in pass-through mode, apache2ctl can take all the Apache arguments in the following syntax:

$ apachectl [apache-argument]
$ apache2ctl [apache-argument]

All the Apache-arguments can be listed as follows:

$ apache2 help    [On Debian based systems]
$ httpd help      [On RHEL based systems]

Check Enabled Apache Modules

Therefore, in order to check which modules are enabled on your Apache web server, run the applicable command below for your distribution, where -t -D DUMP_MODULES is a Apache-argument to show all enabled/loaded modules:

---------------  On Debian based systems --------------- 
$ apache2ctl -t -D DUMP_MODULES   
OR 
$ apache2ctl -M
---------------  On RHEL based systems --------------- 
$ apachectl -t -D DUMP_MODULES   
OR 
$ httpd -M
$ apache2ctl -M
List Apache Enabled Loaded Modules
[root@tecmint httpd]# apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
....

That’s all! in this simple tutorial, we explained how to use the Apache front-end tools to list enabled/loaded apache modules. Keep in mind that you can get in touch using the feedback form below to send us your questions or comments concerning this guide.

Source

Apache Virtual Hosting: IP Based and Name Based Virtual Hosts in RHEL/CentOS/Fedora

As we all are aware that Apache is a very powerful, highly flexible and configurable Web server for Nix OS. Here in this tutorial, we are going to discuss one more feature of Apache which allows us to host more than one website on a single Linux machine. Implementing virtual hosting with Apache web server can help you to save costs you are investing on your server maintenance and their administration.

Don’t MissNGINX Name-based and IP-based Virtual Hosting (Server Blocks)

Apache Virtual Hosting in Linux

Apache Virtual Hosting in Linux

Concept of Shared web hosting and Reseller web hosting is based on this facility of Apache only.

Types of Virtual Host

There are two types of virtual hosting is available with Apache.

Name Based Virtual Hosting

With the name based virtual hosting you can host several domains/websites on a single machine with a singleIP. All domains on that server will be sharing a single IP. It’s easier to configure than IP based virtual hosting, you only need to configure DNS of the domain to map it with its correct IP address and then configure Apache to recognize it with the domain names.

Name Based Virtual Hosting

Name Based Virtual Hosting

IP Based Virtual Hosting

With the IP based virtual hosting, you can assign a separate IP for each domain on a single server, these IP’s can be attached to the server with single NIC cards and as well as multiple NICs.

IP Based Virtual Hosting

IP Based Virtual Hosting

Lets set up Name Based Virtual Hosting and IP based Virtual hosting in RHEL, CentOS and Fedora.

Testing Environment
  1. OS – CentOS 6.5
  2. Application – Apache Web Server
  3. IP Address – 192.168.0.100
  4. IP Address – 192.168.0.101
  5. Domain – www.example1.com
  6. Domain – www.example2.com

How to Setup IP Based and Name Based Apache Virtual Hosts

Before setting up virtual hosting with Apache, your system must have Apache Web software installed. if not, install it using default package installer called yum.

[root@tecmint ~]# yum install httpd

Setup Name Based Virtual Host

But, before creating a virtual host, you need to create a directory where you will keep all your website’s files. So, create directories for these two virtual hosts under /var/www/html folder. Please remember /var/www/html will be your default Document Root in the Apache virtual configuration.

[root@tecmint ~]# mkdir /var/www/html/example1.com/
[root@tecmint ~]# mkdir /var/www/html/example2.com/

To set up Name based virtual hosting you must need to tell Apache to which IP you will be using to receive the Apache requests for all the websites or domain names. We can do this with NameVirtualHost directive. Open Apache main configuration file with VI editor.

[root@tecmint ~]# vi /etc/httpd/conf/httpd.conf

Search for NameVirtualHost and uncomment this line by removing the # sign in front of it.

NameVirtualHost

Next add the IP with possible in which you want to receive Apache requests. After the changes, your file should look like this:

NameVirtualHost 192.168.0.100:80

Now, it’s time to setup Virtual host sections for your domains, move to the bottom of the file by pressing Shift + G. Here in this example, We are setting up virtual host sections for two domains

  1. www.example1.com
  2. www.example2.com

Add the following two virtual directives at the bottom of the file. Save and close the file.

<VirtualHost 192.168.0.100:80>
    ServerAdmin webmaster@example1.com
    DocumentRoot /var/www/html/example1.com
    ServerName www.example1.com
ErrorLog logs/www.example1.com-error_log
CustomLog logs/www.example1.com-access_log common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@example2.com
    DocumentRoot /var/www/html/example2.com
    ServerName www.example2.com
ErrorLog logs/www.example2.com-error_log
CustomLog logs/www.example2.com-access_log common
</VirtualHost>

You are free to add as many directives you want to add in your domains virtual host section. When you are done with changes in httpd.conf file, please check the syntax of files with following command.

[root@tecmint ~]# httpd -t

Syntax OK

It is recommended to check the syntax of the file after making some changes and before restarting the Web server because if any syntax goes wrong Apache will refuse to work with some errors and eventually affect your existing web server go down for a while. If syntax is OK. Please restart your Web server and add it to chkconfigto make your web server start in runlevel 3 and 5 at the boot time only.

[root@tecmint ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@tecmint ~]# chkconfig --level 35 httpd on

Now it’s time to create a test page called index.html add some content to the file so we will have something to check it, when the IP calls the virtual host.

[root@tecmint ~]# vi /var/www/html/example1.com/index.html
<html>
  <head>
    <title>www.example1.com</title>
  </head>
  <body>
    <h1>Hello, Welcome to www.example1.com.</h1>
  </body>
</html>
[root@tecmint ~]# vi /var/www/html/example2.com/index.html
<html>
  <head>
    <title>www.example2.com</title>
  </head>
  <body>
    <h1>Hello, Welcome to www.example2.com.</h1>
  </body>
</html>

Once you’re done with it, you can test the setup by accessing both the domains in a browser.

http://www.example1.com
http://www.example2.com
Preview: www.example1.com

Virtual Hosting: www.example1.com

Virtual Hosting: www.example1.com

Preview: www.example2.com

Virtual Hosting: www.example2.com

Virtual Hosting: www.example2.com

Setup IP Based Virtual Hosting Linux

To setup IP based virtual hosting, you must have more than one IP address/Port assigned to your server or your Linux machine.

It can be on a single NIC card , For example: eth0:1eth0:2eth0:3 … so forth. Multiple NIC cards can also be attached. If you don’t know how to create multiple IP’s on single NIC, follow the below guide, that will help you out in creating.

  1. Create Multiple IP Addresses to One Single Network Interface

Purpose of implementing IP based virtual hosting is to assign implementing for each domain and that particular IP will not be used by any other domain.

This kind of set up required when a website is running with SSL certificate (mod_ssl) or on different ports and IPs. And You can also run multiple instances of Apache on a single machine. To check the IPs attached in your server, please check it using ifconfig command.

root@tecmint ~]# ifconfig
Sample Output
 
eth0      Link encap:Ethernet  HWaddr 08:00:27:4C:EB:CE  
          inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe4c:ebce/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17550 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15120 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:16565983 (15.7 MiB)  TX bytes:2409604 (2.2 MiB)

eth0:1    Link encap:Ethernet  HWaddr 08:00:27:4C:EB:CE  
          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1775 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1775 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3416104 (3.2 MiB)  TX bytes:3416104 (3.2 MiB)

As you can see in above output, two IPs 192.168.0.100 (eth0) and 192.168.0.101 (eth0:1) is attached to the server, both IPs are assigned to the same physical network device (eth0).

Now, assign a specific IP/Port to receive http requests, you can simply do it by changing Listen directive in httpd.conf file.

[root@tecmint ~]# vi /etc/httpd/conf/httpd.conf

Search for word “Listen”, You find a section where the short description about Listen directive is written. In that section, comment the original line and write your own directive below that line.

# Listen 80

Listen 192.168.0.100:80

Now,  create a Virtual host sections for both the domains. Go the bottom of the file and add the following virtual directives.

<VirtualHost 192.168.0.100:80>
    ServerAdmin webmaster@example1.com
    DocumentRoot /var/www/html/example1
    ServerName www.example1.com
ErrorLog logs/www.example1.com-error_log
TransferLog logs/www.example1.com-access_log
</VirtualHost>

<VirtualHost 192.168.0.101:80>
    ServerAdmin webmaster@example2.com
    DocumentRoot /var/www/html/example2
    ServerName www.example2.com
ErrorLog logs/www.example2.com-error_log
TransferLog logs/www.example2.com-access_log
</VirtualHost>

Now, since you have modified main Apache conf file, you need to restart the http service like below.

[root@tecmint ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Test your IP based Virtual hosting setup by accessing the URLs on web browser as shown below.

http://www.example1.com
http://www.example2.com

That’s all with Apache virtual host today, If you’re looking to secure and harden your Apache configuration, then read our article that guides.

  1. 13 Apache Web Server Security and Hardening Tips

Reference Links

Apache Virtual Host Documentation

I’ll be again come with some other Apache tips and trick in my future articles, till then Stay Geeky and connected to Tecmint.com. Do not forget to leave your suggestions about the article in our comment section below.

Source

Setting Up Web Servers Load Balancing Using ‘POUND’ on RHEL/CentOS

POUND is a load balancing program developed by ITSECURITY Company. It is a lightweight open source reverse proxy tool which can be used as a web-server load balancer to distribute load among several servers. There are several advantages POUND gives to end user which are very convenient and does the job right.

  1. Supports virtual hosts.
  2. Configurable.
  3. When a backend server is failed or recovered from a failure, it detects it automatically and bases its load balancing decisions according to that.
  4. It rejects incorrect requests.
  5. No specified browser or webservers.

Let’s have a look at how can get this hack done.

First of all you will need a scenario for better understanding about getting this done. So I will use a scenario where there are two webservers and one gateway server which needs to balance the requests comes to gateway server to webservers.

Pound Gateway Server : 172.16.1.222
Web Server 01 : 172.16.1.204
Web Server 02 : 192.168.1.161

Install Pound Load Balancer in Linux

Pound Web Server Load Balancer

Step1: Install Pound Load Balancer on Gateway Server

1. The easiest way to install Pound is using pre-compiled RPM packages, you can find RPMs for RedHat based distributions at:

  1. http://www.invoca.ch/pub/packages/pound/

Alternatively, Pound can be easily installed from the EPEL repository as shown below.

# yum install epel-release
# yum install Pound

After Pound installed, you can verify whether it is installed by issuing this command.

# rpm –qa |grep Pound

Install Pound Load Balancer

Install Pound Load Balancer

2. Secondly, you need two web-servers to balance the load and make sure you have clear identifiers in order to test the pound configuration works fine.

Here I have two servers bearing IP addresses 172.16.1.204 and 192.168.1.161.

For ease of use, I have created python SimpleHTTPServer to create an instant webserver on both servers. Read about python SimpleHTTPServer

In my scenario, I have my webserver01 running on 172.16.1.204 through port 8888 and webserver02 running on 192.168.1.161 through port 5555.

Pound Webserver 1

Pound Webserver 1

Pound Webserver 2

Pound Webserver 2

Step 2: Configure Pound Load Balancer

3. Now it’s time to make the configurations done. Once you have installed pound successfully, it creates the pound’s config file in /etc, namely pound.cfg.

We have to edit the server and backend details in order to balance the load among the webservers. Go to /etcand open pound.cfg file for editing.

# vi /etc/pound.cfg

Make the changes as suggested below.

ListenHTTP
    Address 172.16.1.222
    Port 80
End

ListenHTTPS
    Address 172.16.1.222
    Port    443
    Cert    "/etc/pki/tls/certs/pound.pem"
End

Service
    BackEnd
        Address 172.16.1.204
        Port    8888
    End

    BackEnd
        Address 192.168.1.161
        Port    5555
    End
End

This is how my pound.cfg file looks like.

Configure Pound Load Balancer

Configure Pound Load Balancer

Under the “ListenHTTP” and “ListenHTTPS” tags, you have to enter the IP address of the server you have installed POUND.

By default a server handles HTTP requests though port 80 and HTTPS requests through port 443. Under the “Service” tag, you can add any amount of sub tags called “BackEnd”. BackEnd tags bears the IP addresses and the port numbers which the webservers are running on.

Now save the file after editing it correctly and restart the POUND service by issuing one of below commands.

# /etc/init.d/pound restart 
OR
# service pound restart
OR
# systemctl restart pound.service

Start Pound Load Balancer

Start Pound Load Balancer

4. Now it’s time to check. Open two web browsers to check whether our configurations work fine. In the address bar type your POUND gateway’s IP address and see what appears.

First request should load the first webserver01 and second request from the other web browser should load the second webserver02.

Check Pound Load Balancing

Check Pound Load Balancing

Furthermore, think of a scenario like if you have two webservers to load balance and one of the server’s performance is good and other’s performance is not so good.

So when load balancing among them, you will have to consider for which server you have to put more weight on. Obviously for the server with good performance specs.

To balance the load like that, you just have to add a single parameter inside the pound.cfg file. Let’s have a look at it.

Think server 192.168.1.161:5555 is the better server. Then you need put more requests flow to that server. Under the “BackEnd” tag which is configured for 192.168.1.161 server, add the parameter “Priority” before the End tag.

Look at below example.

Pound Load Balancing Priority

Pound Load Balancing Priority

The range we can use for the “Priority” parameter is between 1-9. If we do not define it, default value of 5 will be assigned.

Then load will be balanced equally. If we define the Priority number, POUND will load the server with higher priority number more oftenly. So in this case, 192.168.1.161:5555 will be loaded more often than the server 172.16.1.204:8888.

Step 3: Planning Emergency Breakdowns

Emergency Tag: This tag is used to load a server in case of all the back end servers are dead. You can add it before the last End tag of pound.cfg as follows.

“Emergency
           Address 192.168.5.10
           Port        8080
   End”

6. POUND always keep track of which backend servers are alive and which are not. We can define after how many seconds POUND should checkout the backend servers by adding “Alive” parameter in pound.cfg.

You can use the parameter as “Alive 30” for set it to 30 seconds. Pound will temporarily disable the backend servers which are not responding. When we say not responding server may be dead or cannot establish a connection at that moment.

POUND will check the disabled backend server after every time period you have defined in the pound.cfg file in case if the server could establish a connection, then POUND can get back to work with the server.

7. POUND daemon will be handled by poundctl command. By having that we don’t need to edit the pound.cfgfile and we can issue Listner ServerBackEnd servers and sessions etc. via a single command.

Syntax: poundctl -c /path/to/socket [-L/-l] [-S/-s] [-B/-b] [-N/-n] [-H] [-X]
  1. -c defines path to your socket.
  2. -L / -l defines the listener of your architecture.
  3. -S / -s defines the service.
  4. -B / -b defines the backend servers.

See poundctl man pages for more information.

Hope you enjoy this hack and discover more options regarding this. Feel free to comment below for any suggestions and ideas. Keep connected with Tecmint for handy and latest How To’s.

Read AlsoInstalling XR Crossroads Load Balancer for Web Servers

Source

Setting Up ‘XR’ (Crossroads) Load Balancer for Web Servers on RHEL/CentOS

Crossroads is a service independent, open source load balance and fail-over utility for Linux and TCP based services. It can be used for HTTP, HTTPS, SSH, SMTP and DNS etc. It is also a multi-threaded utility which consumes only one memory space which leads to increase the performance when balancing load.

Let’s have a look at how XR works. We can locate XR between network clients and a nest of servers which dispatches client requests to the servers balancing the load.

If a server is down, XR forwards next client request to the next server in line, so client feels no down time. Have a look at the below diagram to understand what kind of a situation we are going to handle with XR.

Install XR Crossroads Load Balancer

Install XR Crossroads Load Balancer

There are two web-servers, one gateway server which we install and setup XR to receive client requests and distribute them among the servers.

XR Crossroads Gateway Server : 172.16.1.204
Web Server 01 : 172.16.1.222
Web Server 02 : 192.168.1.161

In above scenario, my gateway server (i.e XR Crossroads) bears the IP address 172.16.1.222webserver01 is 172.16.1.222 and it listens through port 8888 and webserver02 is 192.168.1.161 and it listens through port 5555.

Now all I need is to balance the load of all the requests that receives by the XR gateway from internet and distribute them among two web-servers balancing the load.

Step1: Install XR Crossroads Load Balancer on Gateway Server

1. Unfortunately, there isn’t any binary RPM packages available for crosscroads, the only way to install XR crossroads from source tarball.

To compile XR, you must have C++ compiler and Gnu make utilities installed on the system in order to continue installation error free.

# yum install gcc gcc-c++ make

Next, download the source tarball by going to their official site (https://crossroads.e-tunity.com), and grab the archived package (i.e. crossroads-stable.tar.gz).

Alternatively, you may use following wget utility to download the package and extract it in any location (eg: /usr/src/), go to unpacked directory and issue “make install” command.

# wget https://crossroads.e-tunity.com/downloads/crossroads-stable.tar.gz
# tar -xvf crossroads-stable.tar.gz
# cd crossroads-2.74/
# make install

Install XR Crossroads Load Balancer

Install XR Crossroads Load Balancer

After installation finishes, the binary files are created under /usr/sbin/ and XR configuration within /etc namely “xrctl.xml”.

2. As the last prerequisite, you need two web-servers. For ease of use, I have created two python SimpleHTTPServer instances in one server.

To see how to setup a python SimpleHTTPServer, read our article at Create Two Web Servers Easily Using SimpleHTTPServer.

As I said, we’re using two web-servers, and they are webserver01 running on 172.16.1.222 through port 8888and webserver02 running on 192.168.1.161 through port 5555.

XR WebServer 01

XR WebServer 01

XR WebServer 02

XR WebServer 02

Step 2: Configure XR Crossroads Load Balancer

3. All requisites are in place. Now what we have to do is configure the xrctl.xml file to distribute the load among the web-servers which receives by the XR server from the internet.

Now open xrctl.xml file with vi/vim editor.

# vim /etc/xrctl.xml

and make the changes as suggested below.

<?xml version=<94>1.0<94> encoding=<94>UTF-8<94>?>
<configuration>
<system>
<uselogger>true</uselogger>
<logdir>/tmp</logdir>
</system>
<service>
<name>Tecmint</name>
<server>
<address>172.16.1.204:8080</address>
<type>tcp</type>
<webinterface>0:8010</webinterface>
<verbose>yes</verbose>
<clientreadtimeout>0</clientreadtimeout>
<clientwritetimout>0</clientwritetimeout>
<backendreadtimeout>0</backendreadtimeout>
<backendwritetimeout>0</backendwritetimeout>
</server>
<backend>
<address>172.16.1.222:8888</address>
</backend>
<backend>
<address>192.168.1.161:5555</address>
</backend>
</service>
</configuration>

Configure XR Crossroads Load Balancer

Configure XR Crossroads Load Balancer

Here, you can see a very basic XR configuration done within xrctl.xml. I have defined what the XR server is, what are the back end servers and their ports and web interface port for the XR.

4. Now you need to start the XR daemon by issuing below commands.

# xrctl start
# xrctl status

Start XR Crossroads

Start XR Crossroads

5. Okay great. Now it’s time to check whether the configs are working fine. Open two web browsers and enter the IP address of the XR server with port and see the output.

Verify Web Server Load Balancing

Verify Web Server Load Balancing

Fantastic. It works fine. now it’s time to play with XR.

6. Now it’s time to login into XR Crossroads dashboard and see the port we’ve configured for web-interface. Enter your XR server’s IP address with the port number for web-interface you have configured in xrctl.xml.

http://172.16.1.204:8010

XR Crossroads Dashboard

XR Crossroads Dashboard

This is what it looks like. It’s easy to understand, user-friendly and easy to use. It shows how many connections each back end server received in the top right corner along with the additional details regarding the requests receiving. Even you can set the load weight each server you need to bear, maximum number of connections and load average etc..

The best part is, you actually can do this even without configuring xrctl.xml. Only thing you have to do is issue the command with following syntax and it will do the job done.

# xr --verbose --server tcp:172.16.1.204:8080 --backend 172.16.1.222:8888 --backend 192.168.1.161:5555

Explanation of above syntax in detail:

  1. –verbose will show what happens when the command has executed.
  2. –server defines the XR server you have installed the package in.
  3. –backend defines the webservers you need to balance the traffic to.
  4. Tcp defines it uses tcp services.

For more details, about documentations and configuration of CROSSROADS, please visit their official site at: https://crossroads.e-tunity.com/.

XR Corssroads enables many ways to enhance your server performance, protect downtime’s and make your admin tasks easier and handier. Hope you enjoyed the guide and feel free to comment below for the suggestions and clarifications.

Read AlsoInstalling Pound Load Balancer to Control Web Server Load

Source

WP2Social Auto Publish Powered By : XYZScripts.com