Linux Pathfinder: Linux Howtos and Tutorials

Install Apache 2.4 from Source on Ubuntu

Install Apache 2.4 from Source on Ubuntu

Apache Server (HTTP) is a free open source web server for Unix-like systems, windows and other operating systems. We’ll discuss about to install Apache 2.4 from source compilation and detailed information about Web server on linux system. This article will be helpful for those who don’t know compilation of software from source.

Install build essentials on Ubuntu server.

sudo apt-get install build-essential
cd /usr/local/src

Zlib is a library for compression method which found in gzip. This package includes the shared library.

 tar xvfz zlib-1.2.8.tar.gz
 cd zlib-1.2.8/
 ./configure --prefix=/usr/local
 make install

Install Apache 2.4

Download the Apache 2.4 source files from the following URL:

cd /usr/local/src

Extract the apache source:

tar xvfz httpd-2.4.10.tar.gz
cd httpd-2.4.10/

Now install and configure the Apache 2.4 server that we want:

We are going to run Apache path and required modules with a script as shown below.

chmod +x configure.nice
#! /bin/sh
 # Created by configure
"./configure" \
 "--prefix=/usr/local/apache2" \
 "--enable-cgi" \
 "--enable-info" \
 "--enable-speling" \
 "--enable-usertrack" \
 "--enable-deflate" \
 "--enable-ssl" \
 "--enable-proxy" \
 "--enable-proxy-connect" \
 "--enable-proxy-ftp" \
 "--enable-expires" \
 "--enable-headers" \
 "--enable-proxy-http" \
 "--enable-rewrite" \
 "--enable-so" \
 "--enable-proxy-balancer" \
 "--with-included-apr" \

Once the configuration is complete then:

make install

Let’s test that is it working now:

/usr/local/apache2/bin/apachectl start

Now open your browser and put http://localhost or your machine ip address and you should see a message saying “It works!”.

Stop Apache:

/usr/local/apache2/bin/apachectl stop

Apache at start-up

Now let’s get Apache to start at boot time automatically:

cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
chmod +x /etc/init.d/apachectl

We’ll copy the apache control script into the start-up directory.

Now we need to register it with the start-up manager:


We’ll prepare base script, we need to add it to the default run levels:

sudo /usr/sbin/update-rc.d -f apachectl defaults

Securing Apache

We’ll create a dedicate Apache system user account. It’ll make your install much more secure.

sudo adduser --system apache

Now we just need to make sure that Apache runs under this user. We do that by editing the configuration file:

vim /usr/local/apache2/conf/httpd.conf

You need to find the lines that say:

User daemon
Group daemon

And change them so they look like:

User apache
Group nogroup

Save the file.

Now, let’s start Apache:

/usr/local/apache2/bin/apachectl start

Now to check it’s running under the new user, apache:

ps -aux | grep httpd

If you see the word apache in there, it’s working.
Check it’s all working

Now just reboot the system and before logging in, check on another machine by visiting the servers IP in the web browser and you should see the “It works!” message. This means Apache started up correctly automatically.

Share this article:

Asif Khan's picture
I am an experienced Linux System and Network Administrator with having more than 10 years of experience. My primary responsibilities are to keep up and running Linux system environment, backups important data with scripting and configuration management on AWS Linux server environments. My aim is to help people, in finding their path towards a solution to their problems. Well, I believe helping others can good for both parties, to them and to you as well. That day and today is the day that thousands of people seek help from my website to help people find answers to their questions. I am sure that everyone will get all the answers to their questions related to software and operating system, and this website will help you keep your system updated.

Add new comment


Enter the characters shown in the image.