This post is a step-to-step tutorial to install Apache 2 from source-code on Unix-Like Systems like Linux, Open Solaris and FreeBSD.
Step 1 - Verifying the Requirements
- The Disk Space that you need for the Apache installation must be at least 50MB. In any case Apache use about 10 MB after the installation.
- ANSI-C Compiler - On your system you must have an ANSI-C compiler installed like the GNU C Compiler (GCC).
- Packages and Libraries - Some packages and libraries are needed to install Apache. Some packages are make, autoconf, libtool, OpenSSL.
- Optional Requirements - Apache can use some scripts, like apxs, which are written in Perl. That depends on your apache configuration, so it’s possible that you need the Perl 5 Interpreter.
Step 2 - Download & Extract Apache Source Code
In succession some simple steps to download and extract the Apache source code. Steps below are tested on Open Suse 11.1 Linux distribution but i think that you can follow their without change or, at most, with some little difference. In order to install Apache2 you have to get the source code and then you have to extract the files from the tar.gz archive downloaded. So you have choose the url where you get the apache source code. In the example, I have chosen the apache version 2.2.11, you can get here. Below you can see the Apache download step using wget unix/linux command:
/usr/local/src # wget http://www.apache.org/dist/httpd/httpd-2.2.11.tar.gz
–2009-03-02 11:07:29– http://www.apache.org/dist/httpd/httpd-2.2.11.tar.gz
Resolving www.apache.org… 192.87.106.226
Connecting to www.apache.org|192.87.106.226|:80… connected.
HTTP request sent, awaiting response… 200 OK Length: 6806786 (6.5M) [application/x-gzip]
Saving to: `httpd-2.2.11.tar.gz.1′
[100%=========================================>] 6,806,786 1.29M/s in 8.1s
2009-03-02 11:07:37 (824 KB/s) - `httpd-2.2.11.tar.gz.1′ saved [6806786/6806786]
/usr/local/src #After downloaded the code you have to extract it. In the example, I have used the ’/usr/local/src’ path but you can use what you want of course. Below the step to extract the code using tar unix/linux command:
/usr/local/src # tar xzvf httpd-2.2.11.tar.gz
………………………………………………………………
………………………………………………………………
httpd-2.2.11/modules/debug/README
httpd-2.2.11/README
httpd-2.2.11/apachenw.mcp.zip
httpd-2.2.11/buildconf
httpd-2.2.11/libhttpd.dsp
httpd-2.2.11/LAYOUT
httpd-2.2.11/.deps
usr/local/src #Step 3 - Configure Apache
Before installing Apache you have to configure it. That’s a very important step to fit and customize the installation for your platform and need. In the example below, I have used some option to customize my apache installation. Below there are some option descriptions and reference link that I’ve used in my Apache installation.
- –with-included-apr - This option allows to use the apr and apr-util 1.2 libraries bundled with apache distribution simplified the installation, so you don’t have any problems if your system have an older version than 1.2.
- –prefix=/usr/local/myapache2 - This option allows to define a directory installation. The default value is /usr/local/apache2.
- –enable-maintainer-mode - It allows to enable the debug and warnings during the installation process. I think is a useful option to understand what happen during the installation.
- –enable-dav- With this option it’s possible to enable the WebDAV protocol. See here for more details.
- –enable-dav-fs - See here for more details.
- –enable-dav-lock - See here for more details.
- –enable-auth-digest - Enable the apache module mod_auth_digestfor user authentication using MD5 Digest Authentication.
- –enable-rewrite - Enable the apache module mod_rewrite to allow to rewrite requested URLs on the fly. This option is very useful in many case, think about using the permalink in WordPress for example. AskApache is a good web site about Apache, you can find more information and tips and tricks about apache module mod_rewrite here.
- –enable-ssl=/usr/ssl - With this option you can use the protocols SSL/TLS using the apache module mod_ssl.
You can also use the default Apache configuration of course. In this case you have use the configure script without options. To know more details see the Apache HTTPD site here. Below you can see the Apache configuration step on my system. Remember you must to use the root user to execute the configure script.
/usr/local/src/httpd-2.2.11 # ./configure –with-included-apr –prefix=/usr/local/myapache2 –enable-mods-shared=”all ssl dav_lock” –enable-maintainer-mode –enable-dav –enable-dav-fs –enable-dav-lock –enable-deflate –enable-auth-digest –enable-rewrite –enable-actions –enable-so –enable-ssl=/usr/ssl
checking for chosen layout…
Apache checking for working mkdir -p…
yes checking build system type…
i686-pc-linux-gnu checking host system type…
i686-pc-linux-gnu checking target system type…
i686-pc-linux-gnu Configuring Apache Portable Runtime library …
configuring package in srclib/apr now
……………………………………………………………………
…………………………………………………………………..
config.status: creating include/ap_config_layout.h
config.status: creating support/apxs
config.status: creating support/apachectl
config.status: creating support/dbmmanage
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
/usr/local/src/httpd-2.2.11 #Step 4 - Build & Install Apache
Finally we can build and Install our Apache HTTP Server. This step is very simple and doesn’t need a lot of comments. Starting to build it we have to use only make command:
/usr/local/src/httpd-2.2.11 # make
Making all in srclib make[1]: Entering directory `/usr/local/src/httpd-2.2.11/srclib’
Making all in apr make[2]: Entering directory `/usr/local/src/httpd-2.2.11/srclib/apr’
make[3]: Entering directory `/usr/local/src/httpd-2.2.11/srclib/apr’
/bin/sh /usr/local/src/httpd-2.2.11/srclib/apr/libtool –silent –mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I./include -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include -o passwd/apr_getpass.lo -c passwd/apr_getpass.c && touch passwd/apr_getpass.lo
/bin/sh /usr/local/src/httpd-2.2.11/srclib/apr/libtool –silent –mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I./include -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include -o strings/apr_fnmatch.lo -c strings/apr_fnmatch.c && touch strings/apr_fnmatch.lo
/bin/sh /usr/local/src/httpd-2.2.11/srclib/apr/libtool –silent –mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I./include -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include -o strings/apr_strnatcmp.lo -c strings/apr_strnatcmp.c && touch strings/apr_strnatcmp.lo
/bin/sh /usr/local/src/httpd-2.2.11/srclib/apr/libtool –silent –mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I./include -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include -o strings/apr_snprintf.lo -c strings/apr_snprintf.c && touch strings/apr_snprintf.lo
^Cmake[3]: *** [strings/apr_snprintf.lo] Interrupt
make[2]: *** [all-recursive] Interrupt
make[1]: *** [all-recursive] Interrupt
make: *** [all-recursive] Interrupt
/usr/local/src/httpd-2.2.11 #Then we can install the Apache HTTP Server. It’s a very simple step. It’s enough to use the command make install and then after, some minutes, you have your Apache Web Server installed
. Below you can see the Apache installation step executed on my system.
usr/local/src/httpd-2.2.11 # make install
Making install in srclib make[1]: Entering directory `/usr/local/src/httpd-2.2.11/srclib’
Making install in apr make[2]: Entering directory `/usr/local/src/httpd-2.2.11/srclib/apr’
/bin/sh /usr/local/src/httpd-2.2.11/srclib/apr/libtool –silent –mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I./include -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include -o strings/apr_snprintf.lo -c strings/apr_snprintf.c && touch strings/apr_snprintf.lo
/bin/sh /usr/local/src/httpd-2.2.11/srclib/apr/libtool –silent –mode=compile gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I./include -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I./include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include/arch/unix -I/usr/local/src/httpd-2.2.11/srclib/apr/include -o strings/apr_strings.lo -c strings/apr_strings.c && touch strings/apr_strings.lo
………………………………………………………………………….
………………………………………………………………………….
Installing configuration files
mkdir /usr/local/myapache2/conf
mkdir /usr/local/myapache2/conf/extra
mkdir /usr/local/myapache2/conf/original
mkdir /usr/local/myapache2/conf/original/extra
Installing HTML documents
mkdir /usr/local/myapache2/htdocs
Installing error documents
mkdir /usr/local/myapache2/error
Installing icons
mkdir /usr/local/myapache2/icons
mkdir /usr/local/myapache2/logs
Installing CGIs
mkdir /usr/local/myapache2/cgi-bin
Installing header files Installing build system files
Installing man pages and online manual
mkdir /usr/local/myapache2/man
mkdir /usr/local/myapache2/man/man1
mkdir /usr/local/myapache2/man/man8
mkdir /usr/local/myapache2/manual
make[1]: Leaving directory `/usr/local/src/httpd-2.2.11′
usr/local/src/httpd-2.2.11 #Step 5 -Customize & Start/Stop Command
This is the last step of our tutorial, we have to customize and test the start/stop of our installation to verify is all OK. I hope so :-) . To customize your Apache Web Server you have to change the httpd.conf file. You can find this file on PREFIX/conf/ directory where PREFIX is the directory where you have chosen to install the web server. In my installation the directory is /usr/local/myapache2. To know more details see here. Now and finally, we can test our installation. So for starting the web server you have to use the command PREFIX/bin/apachectl -k start. Below the step in my installation:
/usr/local/src/httpd-2.2.11 # cd /usr/local/myapache2/bin
/usr/local/myapache2/bin # ./apachectl -k start
/usr/local/myapache2/bin #To test if your web server is started correctly you can use a browser and go to http://your_host_name/ if the starting is OK you’ll se the Apache2 home page like this:

Apache HTTP Server Screenshot
At the end, We’re going to try to stop the Apache Web Server. That’s very simple, see below.
/usr/local/myapache2/bin # ./apachectl -k stop
/usr/local/myapache2/bin #If you’d like, you can verify if the Apache Web Server is stopped correctly using browser like already you’ve seen above. You can also test the Apache start/stop using only wget command like showing below:
/usr/local/myapache2/bin # ./apachectl -k start
/usr/local/myapache2/bin # wget http://localhost
–2009-03-04 10:26:55– http://localhost/ Resolving localhost… 127.0.0.1
Connecting to localhost|127.0.0.1|:80… connected.
HTTP request sent, awaiting response… 200 OK Length: 44 Saving to: `index.html.1′ 100%[============================================>] 44 –.-K/s in 0s 2009-03-04 10:26:55 (1.25 MB/s) - `index.html.1′ saved [44/44]
/usr/local/myapache2/bin # ./apachectl -k stop
/usr/local/myapache2/bin # wget http://localhost
–2009-03-04 10:27:06– http://localhost/
Resolving localhost… 127.0.0.1
Connecting to localhost|127.0.0.1|:80… failed: Connection refused.
/usr/local/myapache2/bin #I think that’s all. Enjoy your new Apache Installation ![]()





1 comment so far ↓
Bingo!!!
It was a perfect smooth ride following ur steps.
Thanks!!
Leave a Comment