By using this site you agree to the use of cookies.

Learn more

Share via:

Installing the Apache HTTP Server in Linux

Hot to install the Apache HTTP server in Linux.

Edited: 2017-03-18 02:50

To install Apache from the terminal, you can use the apt-get command 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.

When it is done installing, you should be able to test if it works by entering http://localhost/ in your browser, a standard Apache page is shown if the server has successfully been installed.

If you later want to remove the Apache, simply replace the install part with remove. I.e.:

sudo apt-get remove apache2

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 commands are now working for you, try the below instead:

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