Tips on How to Install Apache on Linux

The process isn't as hard as you think

Localhost Screenshot
Localhost Screenshot. Jennifer Kyrnin

Since Apache is free, it's one of the most popular web servers to install. It also has several features that make it useful for many different types of websites. So, what is Apache? In a nutshell, it is a server used for everything from personal web pages to enterprise level sites.

Get the facts on how to install Apache on a Linux system with this overview. Before you begin, however, you should at least be comfortable working in Linux - changing directories, using tar and gunzip and compiling with make (I'll discuss where to get binaries if you don't want to try compiling your own).

You should also have access to the root account on the server machine.

Download Apache

I recommend downloading the latest stable release. The best place to get Apache is from the Apache HTTP Server download site. Download the source files appropriate to your system. Binary releases for some operating systems are available as well.

Extract the Apache Files

Once you've downloaded the files you need to uncompress them:

gunzip -d httpd-2_0_NN.tar.gz
tar xvf httpd-2_0_NN.tar

This creates a new directory under the current directory with the source files.

Configuring Your Server for Apache

Once you have the files, you need to tell your machine where to find everything by configuring the source files. The easiest way is to accept all the defaults and just type:


Of course, most people don't want to accept just the default choices. The most important option is the prefix=PREFIX option. This specifies the directory where the Apache files will be installed.

You can also set specific environment variables and modules. Some of the modules I like to have installed include:

  • mod_alias - to map different parts of the URL tree
  • mod_include - to parse Server Side Includes
  • mod_mime - to associate file extensions with its MIME-type
  • mod_rewrite - to rewrite URLs on the fly
  • mod_speling (sic) - to help your readers who might misspell URLs
  • mod_ssl - to allow for strong cryptography using SSL
  • mod_userdir - to allow system users to have their own web page directories

Please keep in mind that these aren't all the modules I might install on a given system. Read the details about the modules to determine which ones you need.

Build Apache

As with any source installation, you'll then need to build the installation:

make install

Customize Apache

Assuming that there were no problems, you are ready to customize your Apache configuration. This really just amounts to editing the httpd.conf file. This file is located in the PREFIX/conf directory. I generally edit it with text editor.

vi PREFIX/conf/httpd.conf

Note: you'll need to be root to edit this file.

Follow the instructions in this file to edit your configuration the way you want it. More help is available on the Apache website.

Test Your Apache Server

Open a web browser on the same machine and type http://localhost/ in the address box. You should see a page similar to the one in the partial screen shot above. It will say in big letters "Seeing this instead of the website you expected?" This is good news, as it means your server is installed correctly.

Start Editing/Uploading Pages to Your Newly Installed Apache Web Server

Once your server is up and running you can start posting pages. Have fun building your website!