João Paulo Cercal

Staff Security Engineer at LastPass

  • DevOps

Installing the Apache web server on Linux

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

Read this article in

Well, today I’ll show you how to install the Apache 2 web server. So, let’s go!

Note: When I performed the installation, the latest version of the package was “2.2.19″. So the tutorial will cover that version. However, you’ll download the most recent version, so your file will probably have a different name.

Installing the Apache web server on Linux

First download the latest package containing the Apache source code, in “tar.gz” format, from:

http://httpd.apache.org/download.cgi

Then go to the directory where you downloaded the file and extract it into the "/opt” directory:

1
$ sudo tar xvfz ./httpd-2.2.19.tar.gz -C /opt/

Now enter the directory where the source files were extracted:

1
$ cd /opt/httpd-2.2.19/

Run the following command:

1
$ sudo ./configure --prefix=/usr/local/apache2

Next:

1
$ sudo make && make install

Congratulations, your apache web server is now installed, and we’ll check whether it’s working correctly. To do this, we need to start it and try accessing it using a web browser (e.g.: Mozilla Firefox).

Enter the directory where you installed apache. If you didn’t change the installation path, run the following command:

1
$ cd /usr/local/apache2

Otherwise, run the following command:

1
$ cd /diretorio-em-que-o-apache-foi-instalado

Start apache by running the following command:

1
$ sudo ./bin/apachectl -k start

Now open your preferred browser, requesting the following address: http://localhost.

If everything is right, the following message will appear:

# It works!