wave
Case Studies
Public Cloud
VEXXHOST

How To: Install Apache Server On Ubuntu 16.04.

Heba Naser

Heba Naser

 

Introduction 

The Apache HTTP server is one of the most used web server today. The great features that Apache HTTP includes media assistance, loadable modules and extensive integration with other popular applications.

In this tutorial, you will be introduced to the best way to set up an Apache internet web server on your own Ubuntu 16.04.

 

Prerequisites

For the prerequisites needed before this tutorial, you should have a normal, non-root user with sudo privileges installed on your server. Don’t forget to configure a standard firewall to block non-essential interfaces. When everything is ready to go, you can start accessing your non-root user. 

 

Step 1: Installing Apache

Apache is accessible within Ubuntu’s default software repositories. This will be installed by using standard package management applications.

To start, we will need to update the local package index to bring the upstream changes. When this is completed, we can install the apache2 package:

$ sudo apt-get update
$ sudo apt-get install apache2

After this step, apt-get will install Apache with everything it needs.

 

Step 2: Modifying the Firewall

After step 1 is completed, we must test Apache and change our firewall in order to allow outside access to the default web ports. Assuming that all directions were followed, you will need to have a UFW firewall configured to limit access to your server.

During the previous step, Apache files with UFW to provide a few application profiles. After confirming the setup, apt-get will set up Apache and all necessary dependencies.

We can point the UFW application profiles by inputting:

$ sudo ufw app list

You should get this list of the application profiles:

Output

Available applications:
Apache
Apache Full
Apache Secure
OpenSSH

There will be three profiles available for Apache:

  • Apache: This profile opens only port 80 (normal, unencrypted web traffic)
  • Apache Full: This profile opens both interfaces 80 (unencrypted and normal web traffic) and port 443 (TLS/SSL encrypted traffic)
  • Apache Secure: This profile opens only port 443 (Transport Layer Security (TLS) / Secure Sockets Layer (SSL) encrypted traffic)

For this tutorial, we will enable incoming traffic to the Apache Full profile by inputting:

$ sudo ufw allow 'Apache Full'

You can double-check by inputting:

$ sudo ufw status

You should see this HTTP traffic allowed:

Output

Status : active
To                   Action      From
--                   ------      ----
OpenSSH              ALLOW       Anywhere
Apache Full          ALLOW       Anywhere
OpenSSH (v6)         ALLOW       Anywhere (v6)
Apache Full (v6)     ALLOW       Anywhere (v6)

After step 2, the profile is now on to allow access to the webserver.

 

Step 3: Checking the Web Server

After step 2, Ubuntu 16.04 begins Apache. 

Everything should be up and working. We must double-check the system init system to make sure the service is running by inputting:

$ sudo systemctl status apache2
Output
 apache2.service - LSB: Apache2 web server
 Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
 Drop-In: /lib/systemd/system/apache2.service.d└─apache2-systemd.conf
 Active: active (running) since Wed 2017-08-16 15:23:15 UTC; 1h 5min ago
 Docs: man:systemd-sysv-generator(8)
 Process: 4336 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
 Process: 4359 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
 Tasks: 55
 Memory: 2.3M
 CPU: 4.094s
 CGroup: /system.slice/apache2.service
 ├─4374 /usr/sbin/apache2 -k start
 ├─4377 /usr/sbin/apache2 -k start
 └─4378 /usr/sbin/apache2 -k start
 Aug 16 15:23:14 ubuntu-512mb-nyc3-01 systemd[1]: Stopped LSB: Apache2 web server.
 Aug 16 15:23:14 ubuntu-512mb-nyc3-01 systemd[1]: Starting LSB: Apache2 web server...
 Aug 16 15:23:14 ubuntu-512mb-nyc3-01 apache2[4359]: * Starting Apache httpd web server apache2
 Aug 16 15:23:14 ubuntu-512mb-nyc3-01 apache2[4359]: 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
 Aug 16 15:23:14 ubuntu-512mb-nyc3-01 apache2[4359]: *
 Aug 16 15:23:14 ubuntu-512mb-nyc3-01 systemd[1]: Started LSB: Apache2 web server.

Afterwards, you will ask a webpage from Apache to completely check if all is working well. You can access this through your server’s domain name or IP address.

You will be able to get into the default Apache landing page to verify that everything is working well. Some may not want to set up a domain name, you can definitely use your server’s public IP address. In case you do not know your server’s IP address, here is a few ways to find it.

Start by inputting this at your server’s command prompt:

$ hostname -I

You will get back a few addresses separated by spaces. You can try every address in your browser to check if the addresses work. An option is inputting this, which ought to provide you with the public IP address as seen from a different location on the internet:

$ sudo apt-get install curl
$ curl -4 icanhazip.com

When you have your internet web server’s Internet Protocol (IP) address or domain, enter it into your web browser address bar:

http://server_domain_or_IP

Step 4: Managing the Apache Process

Here are the main management controls to get started with: Starting it after it has been stopped:

$ sudo systemctl start apache2

Stopping it:

$ sudo systemctl stop apache2

Reloading without falling connections:

$ sudo systemctl reload apache2

Disable automatic start when server boots:

$ sudo systemctl disable apache2

Restarting it:

$ sudo systemctl restart apache2

Re-enable the service to begin at boot:

$ sudo systemctl enable apache2

When the server boots again, Apache should start by itself.

 

Step 5: Get Familiar with Important Apache Files and Directories

Now that you know how to handle everything, it is important to know these files and directories.

Content

/var/www/html

Server Configuration

/etc/apache2
/etc/apache2/apache2.conf
/etc/apache2/ports.conf
/etc/apache2/sites-available/
/etc/apache2/sites-enabled/
/etc/apache2/conf-available/
/etc/apache2/conf-enabled/
/etc/apache2/mods-available/
/etc/apache2/mods-enabled/

Server Logs

/var/log/apache2/access.log
/var/log/apache2/error.log

 

Conclusion

If all of these five steps were followed properly, the webserver is now installed correctly. You can now have the best experience with the content and technology you would like to apply.

If you have enjoyed this tutorial, make sure to check all the others on our website. If you have questions, please feel free to contact us and we will be more than happy to assist you.

Don’t forget to follow us on Twitter for news, updates, and announcements – @vexxhost.

 

Would you like to know about Zuul, a CI/CD project gating tool? Download our white paper and get reading!

How to up your DevOps game with Project Gating

Share on Social Media:

OpenStack

Cluster API driver for OpenStack Magnum

Heba Naser

Public Cloud

9000 MTUs (jumbo frames) in all Public Cloud Regions

Heba Naser

Uncategorized

OpenInfra Summit Berlin 2022 VEXXHOST Recap

Heba Naser

Go to Top