Setting up Apache 2 on Ubuntu

Using my black Apple MacBook (Mid 2007), these are the steps I’ve used to set up Apache 2 on Ubuntu 13.10 with virtual hosts.

Out of the box

Once my Ubuntu install had completed I tried my ‘localhost’ in a browser and got a message telling me the page didn’t exist.

Run the following in Terminal to install Apache from the Ubuntu Universe repositories:

sudo apt-get install apache2

Once complete I tried localhost’ again and the infamous ‘It works!’ text appeared!


There are several options for each of these commands – I think I’m right in saying they all do the same thing. Their purpose can be fairly self explanatory but just in case I’ve added a brief note with each.

Start the Apache 2 service; use this command after you have stopped your Apache server for whatever reason:

sudo service apache2 start
sudo start apache2
sudo /etc/init.d/apache2 start

Restart the Apache 2 service; use this command to restart your apache server – this is effectively the same as running ‘stop’ then ‘start’:

sudo service apache2 restart
sudo restart apache2
sudo /etc/init.d/apache2 restart

Reload the Apache 2 service; use this command to gracefully reload the Apache configuration files – use this after making a change to your .conf files:

sudo service apache2 reload
sudo reload apache2
sudo /etc/init.d/apache2 reload

Leave a Reply