Building Apache with mod_ssl and Other ModulesIntroductionThis document is intended to be a down-and-dirty guide to building the Apache web server from source code. The task of building Apache itself from source is not very difficult. However, when you begin to throw additional modules and support programs into the mix, it can begin to get confusing. mod_ssl generally proves to be one of the more difficult modules to install, as it has several dependencies which must be compiled and installed first. These steps were performed numerous times on Slackware Linux boxes ranging in version from 3.5 to 7.0. You should not have problems compiling Apache or any of its modules on almost any modern UNIX operating system. Note that this procedure documents building a static Apache binary without DSO support. This means that the web server needs to be recompiled each time a module is added or removed. You will not be able to dynamically add and remove modules with this method. If you wish to add DSO support to your Apache binary, please see Appendix B. |
||||||||||||||||||||||
Required SoftwareIn order to build our web server, the following packages are needed:
Be sure to download the latest versions available of each of these packages. At the time of writing, the file list above was the latest version of each package. Note that the version of mod_ssl is dependent on the version of Apache, as seen in the file name of mod_ssl, above. Make sure that the mod_ssl and Apache versions match.
Download these modules to a convenient place, such as
$ tar -xzvf apache_1.3.14.tar.gz Compiling Modules and Supporting SoftwareThe first step is to do an initial configuration of Apache. A few modules, such as PHP4, require Apache to have been configured at least once before they can be applied to the Apache source tree. We do not need to specify any special parameters at this point, as we will be doing the actual config of Apache much later. $ cd apache_1.3.14 $ ./configure $ cd ..
The next step is to compile the OpenSSL tools. This will create the
necessary libraries for mod_ssl to compile against, as well as create the
openssl command line tool for doing things like generating SSL
certificates. The default install location for openssl is
$ cd openssl-0.9.6 $ sh config -fPIC $ make $ make install $ cd .. Next, we compile and install Ralf Engelschall's (of mod_ssl fame) MM library. MM, according to the README, "simplifies the usage of shared memory between forked processes under Unix platforms." $ cd mm-1.1.3 $ ./configure --disable-shared $ make $ make install $ cd .. Now, we configure the mod_ssl module. The configuration of mod_ssl is actually nothing more than a patch tool which applies the mod_ssl source to the Apache source tree specified on the configure command line. As such, we don't need to do any actual compilation in the mod_ssl distribution. $ cd mod_ssl-2.7.1-1.3.14.tar.gz $ ./configure --with-apache=../apache_1.3.14 $ cd .. Compiling Optional ModulesAt this point we can install additional modules, such as PHP4 and mod_perl.
PHP is an excellent scripting language for the web. Because PHP is
directly compiled (or loaded as a DSO module) into the web server binary,
it
doesn't suffer from the performance hits of forking and executing a
separate command interpreter. PHP also has built-in support for accessing
many kinds of databases, such as MySQL. If MySQL is not installed in a
typical location
(such as
The $ cd php-4.0.5 $ ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.14 --enable-track-vars $ make $ make install $ cp php.ini-dist /usr/local/lib/php.ini $ cd .. mod_perl is another module which is frequently added to Apache. mod_perl allows Perl code to be run by the web server without having to fork and exec an external interpreter, thereby eliminating the performance hits commonly associated with perl CGI scripts. $ cd mod_perl-1.22 $ perl Makefile.PL \ ? APACHE_SRC=../apache_1.3.14/src \ ? DO_HTTPD=1 \ ? USE_APACI=1 \ ? PREP_HTTPD=1 \ ? EVERYTHING=1 $ make $ make test $ make install $ cd ..
This builds and prepares the mod_perl source for inclusion into the Apache
source tree. The Compiling Apache
Finally, we get to the point where we can build our actual Apache binary.
I like to use the
The EAPI_MM=SYSTEM SSL_BASE=SYSTEM
Next, we tell Apache that we wish to use the GNU-style directory tree with
the root directory of Apache at
The next two lines tell Apache that we want to enable the rewrite and ssl
modules. The rewrite module is a very powerful addition to Apache which
allows the administrator to perform complex address and URL rewriting
tasks. The next line,
The final two lines of the
Once the configuration step is complete, build the web server and install
it. Optionally, use $ cd apache_1.3.14 $ ./config.status $ make $ make certificate $ make install Configuring Apache
A few changes are still necessary at this point in order to fully take
advantage of PHP. Add the following to Apache's # Enable PHP4 support AddType application/x-httpd-php .php AddType application/x-httpd-php .php3 AddType application/x-httpd-php-source .phpsPHP3 is identified by the MIME type application/x-httpd-php3 .
(In case you want to associate the .php3 extension with the
PHP3 handler,
if you compiled that instead of PHP4).
At this point, it may be a good idea to add Starting Apache
Now that the web server has been built and configured, it is time to start
it up and test its functionality. There are two ways to start Apache, by
calling the To start Apache manually, issue the following command as root: $ /usr/local/apache/sbin/httpdNote that this will not enable SSL support. Many of the SSL configuration directives in httpd.conf are surrounded by
<IfDefine></IfDefine> conditionals which only are executed if
the condition they test for is true. In order to enable SSL support, run this
command instead:
$ /usr/local/apache/sbin/httpd -DSSLTo start the web server using apachectl instead, use the
following command:
$ /usr/local/apache/sbin/apachectl startTo start the web server with SSL support, use this command: $ /usr/local/apache/sbin/apachectl startssl |