Apache Installation From Source

Compiling and Installing Apache Version 2.4 from source on Linux OS

We create the folder named ‘sourcecode‘ and ‘apache2‘ in /home

mkdir /home/sourcecode

we will use this directory to keep downloaded file

mkdir /home/apache2

at apache2 we are going to Compiling and Installing Apache.

Prerequisite for Apache installation * important

* Apache source code -Download the latest release of Apache from http://httpd.apache.org/download.cgi

*  APR and APR-Util Source Code Download Apr from http://apr.apache.org/

ANSI-C Compiler and Build System -Make sure you have an ANSI-C compiler installed. The GNU C compiler (GCC) from the Free Software Foundation (FSF) is recommended. If you don’t have GCC then at least make sure your vendor’s compiler is ANSI compliant. In addition, your PATH must contain basic build tools such as make.

Perl-Compatible Regular Expressions Library (PCRE) – Download the source code from http://www.pcre.org or from rpm and package

Step 1: Download

cd /home/sourcecode

wget http://www-eu.apache.org/dist//httpd/httpd-2.4.25.tar.gz

extract Apache here

gzip -d httpd-2.4.25 tar.gz

tar xvf httpd-2.4.25.tar

same way extract APR and APR util

wget http://www-us.apache.org/dist//apr/apr-1.5.2.tar.gz

gzip -d apr-1.5.2.tar.gz

tar xvf apr-1.5.2.tar

mv apr-1.5.2 /home/sourcecode/httpd-2.4.25/srclib/apr

wget http://www-us.apache.org/dist/apr/apr-util-1.5.4.tar.gz

gzip -d apr-util-1.5.4.tar.gz

tar xvf apr-util-1.5.4.tar.gz

mv apr-util-1.5.4 /home/sourcecode/httpd-2.4.25/srclib/apr-util

Step 2:

cd  /home/sourcecode/httpd-2.4.25

./configure –prefix=/home/apache2 –enable-so

First option –prefix tells configure script that we want Apache to be installed in directory apache2

If we don’t provide a prefix option than it’ll be installed in default location, which is /usr/local/apache2.

Second option –enable-so tells configure to enable module so, which allows Apache to load shared modules.

Step 3: make

Step 4: make install

This will install Apache to /home/apache2

Step 5: Test Apache installation is done by starting Apache

/home/apache2/bin/apachectl start

If you get to shell prompt without any error then Apache is started.

Now you open a browser

http://localhost, which should display the default message “It Works!”

Now your apache is ready

Start Apache automatically during system startup

Modify the /etc/rc.d/init.d/httpd script and change apachectl and httpd variable to point to the appropriate new location



Now, you can perform the following to stop and start the Apache

service httpd stop

service httpd start

Setup the Apache to automatically startup during reboot as shown below.

# chkconfig --list httpd
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
# chkconfig --level 2345 httpd on
# chkconfig --list httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Apache configure command Line Example

./configure –prefix=/wwwroot –enable-auth-anon –enable-auth-dbm –enable-auth-digest –enable-file-cache –enable-echo –enable-charset-lite –enable-cache –enable-disk-cache –enable-mem-cache –enable-example –enable-ext-filter –enable-case-filter –enable-case-filter-in –enable-deflate –with-z=/usr/local –enable-mime-magic –enable-cern-meta –enable-expires –enable-headers –enable-usertrack –enable-unique-id –enable-proxy –enable-proxy-connect –enable-proxy-ftp –enable-proxy-http –enable-ssl –with-ssl=/usr/local –enable-optional-hook-export –enable-optional-hook-import –enable-optional-fn-import –enable-optional-fn-export –enable-bucketeer –enable-static-support –enable-static-htpasswd –enable-static-htdigest –enable-static-rotatelogs–enable-static-logresolve –enable-static-htdbm –enable-static-ab –enable-static-checkgid –enable-http –enable-dav –enable-info –enable-cgi –enable-cgid –enable-dav-fs –enable-vhost-alias –enable-rewrite –enable-so

Leave a Reply

Your email address will not be published. Required fields are marked *