Compile Apache

Install, configure and use
Apache, PHP, MySQL
on Linux and Windows.

Compile Apache on Linux

Attention! To compile Apache on Linux you must have root access privilidges. Please, make sure that you do not have other instance of Apache already installed on the system.
This page shows you how to compile Apache Web Server on Ubuntu / Debian Linux (DEB based ditsros) or on Redhat / Fedora (and other RPM bases distributions).
You need to become root:
username@box ~ $ sudo su
or simply:
username@box ~ $ su
The first thing that you will need is building tools, such as make, gcc and etc. If is veryeasy to get them all in one go in Ubuntu / Debain based distros:
username@box ~ $ apt-get install build-essential
On RPM based system you need to install them manually:
username@box ~ $ yum install make
username@box ~ $ yum install gcc
username@box ~ $ yum install cpp
It would be nice to keep all source files in one place. To do so, create a folder:
username@box ~ $ mkdir ~/build
Now you need to download and unpack Apache source code:
username@box ~ $ cd ~/build
username@box ~ $ wget
username@box ~ $ tar -zxvf httpd-2.2.3.tar.gz
username@box ~ $ cd httpd-2.2.3.tar.gz
You might want to use any other version of apache. In this case you need substite 2.2.3 to the desirable version number.
Alternatively, one can get the source code by this way:
username@box ~ $ cd ~/build
username@box ~ $ lynx
username@box ~ $ gzip -d httpd-NN.tar.gz
username@box ~ $ tar xvf httpd-NN.tar
username@box ~ $ cd httpd-NN
This way guarantees that one would get the latest version.
Now you are ready for compilation.
The whole build process consists for 3 steps:
  • configure
    This step allows you to switch on or off some application features. All that you will switch on will be comiled into the application automatically adn all you will swith off will be avoided from compilation and the features would not be available unless you recompile it again. Normally, you can get all available configure options by
    username@box ~ $ ./configure --help
    This is a list of all avaialbe Apache configure options:
    Usage: configure [options]
    Options: [defaults in brackets after descriptions]
    General options:
    --quiet, --silent do not print messages
    --verbose, -v print even more messages
    --shadow[=DIR] switch to a shadow tree (under DIR) for building
    Stand-alone options:
    --help, -h print this message
    --show-layout print installation path layout (check and debug)
    Installation layout options:
    --with-layout=[F:]ID use installation path layout ID (from file F)
    --target=TARGET install name-associated files using basename TARGET
    --prefix=PREFIX install architecture-independent files in PREFIX
    --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
    --bindir=DIR install user executables in DIR
    --sbindir=DIR install sysadmin executables in DIR
    --libexecdir=DIR install program executables in DIR
    --mandir=DIR install manual pages in DIR
    --sysconfdir=DIR install configuration files in DIR
    --datadir=DIR install read-only data files in DIR
    --iconsdir=DIR install read-only icon files in DIR
    --htdocsdir=DIR install read-only welcome pages in DIR
    --manualdir=DIR install read-only on-line documentation in DIR
    --cgidir=DIR install read-only cgi files in DIR
    --includedir=DIR install includes files in DIR
    --localstatedir=DIR install modifiable data files in DIR
    --runtimedir=DIR install runtime data in DIR
    --logfiledir=DIR install logfile data in DIR
    --proxycachedir=DIR install proxy cache data in DIR
    Configuration options:
    --enable-rule=NAME enable a particular Rule named 'NAME'
    --disable-rule=NAME disable a particular Rule named 'NAME'
    [IRIXN32=yes IRIXNIS=no PARANOID=no ]
    [SHARED_CHAIN=default SHARED_CORE=default SOCKS4]
    [SOCKS5=no WANTHSREGEX=default ]
    --add-module=FILE on-the-fly copy & activate a 3rd-party Module
    --activate-module=FILE on-the-fly activate existing 3rd-party Module
    --permute-module=N1:N2 on-the-fly permute module 'N1' with module 'N2'
    --enable-module=NAME enable a particular Module named 'NAME'
    --disable-module=NAME disable a particular Module named 'NAME'
    [access=yes actions=yes alias=yes ]
    [asis=yes auth_anon=no auth_dbm=no ]
    [auth_db=no auth_digest=no auth=yes ]
    [autoindex=yes cern_meta=no cgi=yes ]
    [digest=no dir=yes env=yes ]
    [example=no expires=no headers=no ]
    [imap=yes include=yes info=no ]
    [log_agent=no log_config=yes log_forensic=no]
    [log_referer=no mime_magic=no mime=yes ]
    [mmap_static=no negotiation=yes proxy=no ]
    [rewrite=no setenvif=yes so=no ]
    [speling=no status=yes unique_id=no ]
    [userdir=yes usertrack=no vhost_alias=no ]
    --enable-shared=NAME enable build of Module named 'NAME' as a DSO
    --disable-shared=NAME disable build of Module named 'NAME' as a DSO
    --with-perl=FILE path to the optional Perl interpreter
    --with-port=PORT set the port number for httpd.conf
    --without-support disable the build and installation of support tools
    --without-confadjust disable the user/situation adjustments in config
    --without-execstrip disable the stripping of executables on installation
    --server-uid=UID set the user ID the web server should run as [nobody]
    --server-gid=GID set the group ID the web server UID is a memeber of [#-1]
    suEXEC options:
    --enable-suexec enable the suEXEC feature
    --suexec-caller=NAME set the suEXEC username of the allowed caller [www]
    --suexec-docroot=DIR set the suEXEC root directory [PREFIX/share/htdocs]
    --suexec-logfile=FILE set the suEXEC logfile [PREFIX/var/log/suexec_log]
    --suexec-userdir=DIR set the suEXEC user subdirectory [public_html]
    --suexec-uidmin=UID set the suEXEC minimal allowed UID [100]
    --suexec-gidmin=GID set the suEXEC minimal allowed GID [100]
    --suexec-safepath=PATH set the suEXEC safe PATH [/usr/local/bin:/usr/bin:/bin]
    --suexec-umask=UMASK set the umask for the suEXEC'd script [server's umask]
    Deprecated options:
    --layout backward compat only: use --show-layout
    --compat backward compat only: use --with-layout=Apache
    Let's say we want to Apache to leave in /usr/local/apache, be able to proxy requests to other Apache and have share modules enabled to plug in PHP as a shared module. All we need to do is:
    username@box ~ $ ./configure --prefix=/usr/local/apache --enable-module=proxy --enable-module=so
  • compile (make)
    This is actual compiling It takes a while and depends on the CPU and Memory recources you have. All you need to do is:
    username@box ~ $ make
    And wait untillit finishes. It it is interruped with errors then either you do not have all build tools and you need just apt-get / yum them or you do not have appropriate libs. Dig the Internet then.
  • install compiled (make install)
    Now you have eveything compiled. you need just to install it. Install means creating appropriate folders, copying right to rigth folders, setting the initial configuration files. All these happens automatically. All you need to kick off the isntall procees is:
    username@box ~ $ make install
    Congratulations! You have compiled and install Apache. It is not running yet. To run it do:
    username@box ~ $ /usr/local/apache/bin/apachectl start
    The location to apachectl might be different. We used the one used in the example above. To identify you path to apachectl do:
    username@box ~ $ whereis apachectl
Actually that is it. Now you have Apache configured by default up and runnning. You can test it my launching your browser and typing the IP address in address bar. Obviously you have to be sure that ther eis no firewall bewteen your browser and apache box.
Just to remind you the sequence of commands (do not forget to become root and have build-essentials installed.):
username@box ~ $ mkdir ~/build
username@box ~ $ cd ~/build
username@box ~ $ wget
username@box ~ $ tar -zxvf httpd-2.2.3.tar.gz
username@box ~ $ ./configure --prefix=/usr/local/apache --enable-module=proxy --enable-module=so
username@box ~ $ make
username@box ~ $ make install
username@box ~ $ /usr/local/apache/bin/apachectl start