By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Installing apache on Ubuntu

Tutorial on how to install apache on Ubuntu from the package manager.

Edited: 2015-11-07 17:21

To install Apache on Ubuntu/linus you will need to navigate to the package manager, search for apache2 and install the relevant package.

When you have done this you should be able to hit in http://localhost/ in your browser, and view the standard page delivered by your server.

If you want to install Apache on a server in the cloud, you can do so from the terminal, after connecting to your server.

Installing from Terminal

You can also install Apache from the terminal, this is done by using the apt-get command, but you also need to run it with sudo. I.e.

sudo apt-get install apache2

Running the above command will ask us for our root password, since we are running it with sudo. The install part should be self-explanatory – should you later want to remove the Apache HTTP server from your system, simply replace install with remove. I.e.:

sudo apt-get remove apache2

Video showing how to install Apache2, PHP and MySQL in Ubuntu

The below video demonstrates how to install Apache2 with PHP and an MySQL server.

Starting and Stopping the server

To start and stop the server, you can try using the following terminal commands.

sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart

In case the above doesn't work you can also try the below:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart

See also

  1. Location of Apache Configuration files
  2. Location of Apache logs in Ubuntu