Install Apache Web Server

A short tutorial on how to install the Apache web server.

In this tutorial I use the APT package manager to install Apache so in theory this will on any other Linux distribution that also supports APT, in this instance I installed it onto a Raspberry Pi 2 running Raspbian OS.

Before do anything it is advisable to use the following command to make sure have all the latest packages available before installation:

sudo apt update

Then run the following command to install the Apache web server (note it is referred using apache2)

sudo apt install apache2 -y 

I add the ‘-y’ switch to end of the command to automatically agree to the installation of the apache2 package and any additional required packages.

And that’s it, the Apache web server is now installed and running.

You can check to see if everything is working by opening any web browser and going to IP address/hostname of the web server or if you are on the machine localhost will work.

You should see the standard Apache server test page as shown below:

Some useful commands for the Apache web server are:

sudo service apache2 start (starts the Apache service)

sudo service apache2 stops (stops the Apache service)

sudo service apache2 restart (restarts the Apache service)

sudo service apache2 status (check the status of the Apache service)

The default document root of the Apache web-server is /var/www/html so you can place any web pages in that directory.

The Apache web-server also allows you to setup virtual directories so that you can host multiple websites from the same server located under the /var/www directory which I will cover in a future post.

Leave a Reply

Your email address will not be published. Required fields are marked *