Using Apache With RPM Based Systems (Redhat / CentOS / Fedora)
While many distributions make Apache httpd available as operating system supported packages, it can sometimes be desirable to install and use the canonical version of Apache httpd on these systems, replacing the natively provided versions of the packages.
While the Apache httpd project does not currently create binary RPMs for the various distributions out there, it is easy to build your own binary RPMs from the canonical Apache httpd tarball.
This document explains how to build, install, configure and run Apache httpd 2.4 under Unix systems supporting the RPM packaging format.
The Apache httpd source tarball can be converted into an SRPM as follows:
rpmbuild -ts httpd-2.4.x.tar.bz2
RPMs can be built directly from the Apache httpd source tarballs using the following command:
rpmbuild -tb httpd-2.4.x.tar.bz2
Corresponding "-devel" packages will be required to be installed on your build system prior to building the RPMs, the
rpmbuild command will automatically calculate what RPMs are required and will list any dependencies that are missing on your system. These "-devel" packages will not be required after the build is completed, and can be safely removed.
If successful, the following RPMs will be created:
- The core server and basic module set.
- Debugging symbols for the server and all modules.
- Headers and development files for the server.
- The webserver manual.
- Supporting tools for the webserver.
mod_authnz_ldap, with corresponding dependency on openldap.
mod_luamodule, with corresponding dependency on lua.
mod_proxy_htmlmodule, with corresponding dependency on libxml2.
mod_socache_dcmodule, with corresponding dependency on distcache.
mod_sslmodule, with corresponding dependency on openssl.
httpd RPM is the only RPM necessary to get a basic server to run. Install it as follows:
rpm -U httpd-2.4.x-1.i686.rpm
Self contained modules are included with the server. Modules that depend on external libraries are provided as separate RPMs to install if needed.
The default configuration for the server is installed by default beneath the
/etc/httpd directory, with logs written by default to
/var/log/httpd. The environment for the webserver is set by default within the optional
Start the server as follows:
service httpd restart
It is possible to configure additional instances of the Apache httpd server running independently alongside each other on the same machine. These instances can have independent configurations, and can potentially run as separate users if so configured.
This was done by making the httpd startup script aware of its own name. This name is then used to find the environment file for the server, and in turn, the server root of the server instance.
To create an additional instance called
httpd-additional, follow these steps:
- Create a symbolic link to the startup script for the additional server:
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd-additional
chkconfig --add httpd-additional
- Create an environment file for the server, using the
/etc/sysconfig/httpdfile as a template:
# template from httpd
cp /etc/sysconfig/httpd /etc/sysconfig/httpd-additional
# blank template
/etc/sysconfig/httpd-additionaland pass the server root of the new server instance within the
OPTIONS="-d /etc/httpd-additional -f conf/httpd-additional.conf"
- Edit the server configuration file
/etc/httpd-additional/conf/httpd-additional.confto ensure the correct ports and paths are configured.
- Start the server as follows:
service httpd-additional restart
- Repeat this process as required for each server instance.