Prerequsities

SSH access to Ubuntu 18.04 SUDO privilege

Install Apache on Ubuntu 18.04

First of all, Login to your Ubuntu 18.04 system via SSH and update the Apt cache. Then install Apache2 HTTP server packages as following: To install most latest version of Apache use the following PPA.

Manage Apache Service

Apache service is managed with systemctl command line. After installation, use the following command to check the status of Apache service.

Here is the other commands to stop, start or restart Apache service via command line.

Test Apache Setup

Use the following command to view the installed Apache version on your Ubuntu 18.04 Linux system. Now access your Apache server using the server’s IP address or a domain pointed to the server IP. You will see a default Apache page on web browser. It means Apache web server has successfully installed on your Ubuntu 18.04 system.

Create New VirtualHost

Let’s create the first virtual host on your Apache server. For the tutorial, we are using sample domain “example.com”. Here we will create a Virtual host for example.com on port 80. Create a directory and create a sample index file in a directory: Then create Virtualhost configuration file and edit in editor: Add the following content in configuration file. You may change the domain name as per your domain.

Save the Virtualhost configuration file, then enable Virtualhost and reload the Apache service using the following commands:

Configure SSL VirtualHost

You can skip this step if you don’t need SSL. But the security is always the primary concert for any website. The default Apache https listen on port 443. Make sure no other services using the same port. Now, you need to enable Apache ssl module, which is disabled by default. For the tutorial, I have followed these instructions to generate a self signed SSL certificate for our domain. Then create a new Virtual host file and edit it: with the following content:

Here is three terms used to configure SSL virtualhost:

SSLEngine – Set this to “on” SSLCertificateFile – Set the path of your SSL certificate SSLCertificateKeyFile – This is the private key files used to generate SSL certificate

After that enable the Virtualhost and reload the Apache service using the following commands:

Secure Apache Server

Edit the Apache security configuration file Here is the multiple security related settings. Add or Update the following settings. We are not going in detailed discriptions about it but these settings are very useful for the production servers.

Now edit SSL configuration file. Here you can set the server wide SSL protocol and SSLCipherSuite to use secure Cipers to serve your website.

After making changes restart the Apache service to apply new configuration.

Conclusion

All done, You have installed and secured Apache server on your Ubuntu 18.04 Bionic Linux system.

How to Install and Configure Apache on Ubuntu 18 04 LTS   TecAdmin - 33How to Install and Configure Apache on Ubuntu 18 04 LTS   TecAdmin - 90