Secure Installation and Configuration - Checking and Installing Apache (Page 4 of 11 )
Finally Checking Apache
You can now check if your Apache packages have been tampered with or not:
[merc@merc merc]$ gpg --verify httpd-2.0.48.tar.gz.asc httpd-2.0.48.tar.gz
gpg: Signature made Mon 07 Jul 2003 22:56:49 WST using DSA key ID DE885DD3
gpg: Good signature from "Sander Striker <STRIKER@APACHE.ORG>"
gpg: aka "Sander Striker <striker@striker.nl>"
[merc@merc merc]$
What would happen if there were problems? You would receive a warning message from GnuPG. For example:
[merc@localhost merc]$ cp httpd-2.0.48.tar.gz httpd-2.0.48.tar.gz.CORRUPTED
[merc@localhost merc]$ ls -l >> httpd-2.0.48.tar.gz.CORRUPTED
[merc@localhost merc]$ gpg --verify httpd-2.0.48.tar.gz.asc httpd-2.0.48.tar.gz.CORRUPTED
gpg: Signature made Sat 10 Aug 2002 01:51:45 AM WST using DSA key ID DE885DD3
gpg: BAD signature from "Sander Striker <striker@apache.org>" [merc@localhost merc]$
To generate the above warning, I created a spare copy of the Apache server and appended some garbage at the end of the file, making it slightly different. I then ran GnuPG to verify the package and found it faulty. If this error actually occurred, you would have to warn the webmaster immediately of the discrepancy.
NOTE At the address http://httpd.apache.org/dev/verification.html you will find a short guide that describes how to check your Apache packages |
GNUPG: Is All This Necessary? At this point, you should have successfully downloaded Apache and ensured that the package is an authentic copy distributed by the Apache Software Foundation. You should also be familiar with GnuPG and have a glimpse of its potential.
Running such thorough checks might seem a bit meticulous, but for a professional system administrator, there is no room for being slack. The main web server or the local mirror may have been hacked, and the downloaded Apache package may have been modified. This scenario, that seemed to be science fiction a few months ago, became reality when the main Debian web server was cracked, and nobody was absolutely sure if any of the distribution’s packages had been modified. This episode has opened a lot of eyes to the value of signature checking.
Some system administrators consider the MD5 checksum a safe enough method for checking the validity of a package. MD5 is an algorithm that aims to return a truly unique integer number when given a list of bytes in input. This means that the MD5 checksum for two different files is guaranteed to be different. The md5sum command can be used to calculate the MD5 checksum of a file, and the result is printed on the standard output. Although MD5 checksums can be useful in checking that a file was downloaded correctly (you can easily run md5sum and compare your checksum to what it should be), it should not be used to check that an Apache package is genuine.
Installing Apache In this section I provide a short explanation on how I installed the Apache servers (both 1.3. x and 2. x versions) that I will use in the rest of the book.
Apache and Dynamic Modules Apache comes with a wide set of modules that are not part of the core server, and can be compiled as dynamic modules (they can be loaded into the main server if they are needed). An example of a module in Apache that may be compiled as loadable is autoindex, which is responsible for generating a directory index in HTML (and is therefore well formatted if seen through a browser). This may seem totally useless to your server, but it could be useful later on.
Apache can be built as a static server, or as a dynamic server; it depends on what options you set when you run configure. Apache can actually be built as a mix, with some of the modules built in the main server, and others available as loadable modules.
As far as security is concerned, I believe it is a good idea to compile most of the modules dynamically, and leave the main server stripped to the bones. There are several advantages to doing so:
- You can compile all the modules available, but leave them out of the server to save some memory.
- You can add modules later, without having to recompile the whole server.
- If a security problem is discovered in one of the modules, you can easily disable it until the problem is dealt with. Therefore, you need to configure your Apache so that your web site won’t be defaced if you disable any of the modules.
- If a new version of a module comes out (such as PHP), you can easily upgrade it without having to recompile the whole server.
You can get a detailed description of the modules from http://httpd.apache.org/docs-2.0/mod/ or from http://httpd.apache.org/docs/mod/.
Apache 1.3.x
The following are the commands I used to install Apache 1.3. x on my server. The options --enable-module=most --enable-shared=max compile most modules as shared objects (“most” excludes mod_auth_db, which is sometimes considered to be problematic to compile, and mod_log_agent and mod_log_referer, which are both deprecated). This Apache’s directory will be /usr/local/apache1.
[root@merc apache_source]# tar xvzf apache_1.3.29.tar.gz
apache_1.3.29/
apache_1.3.29/cgi-bin/
apache_1.3.29/cgi-bin/printenv
apache_1.3.29/cgi-bin/test-cgi
[...]
apache_1.3.29/src/support/suexec.8
apache_1.3.29/src/support/suexec.c
apache_1.3.29/src/support/suexec.h apache_1.3.29/src/Configuration
[root@merc apache_source]# cd apache_1.3.29
[root@merc apache_1.3.29]# ./configure --prefix=/usr/local/apache1 --enable-module=most --enable-shared=max
Configuring for Apache, Version 1.3.29
+ using installation path layout: Apache (config.layout)
[...]
Creating Makefile in src/modules/standard
Creating Makefile in src/modules/proxy
[root@merc apache_1.3.29]# make
===> src
make[1]: Entering directory `/root/apache
_source/apache_1.3.29'
make[2]: Entering directory `/root/apache
_source/apache_1.3.29/src'
===> src/regex
sh ./mkh -p regcomp.c >regcomp.i
[...]
make[2]: Leaving directory `/root/apache
_source/apache_1.3.29/src/support'
<=== src/support
make[1]: Leaving directory `/root/apache
_source/apache_1.3.29' <=== src
[root@merc apache_1.3.29]# make install
make[1]: Entering directory `/root/apache
_source/apache_1.3.29'
===> [mktree: Creating Apache installation tree]
./src/helpers/mkdir.sh /usr/local/apache1/bin
mkdir /usr/local/apache1
mkdir /usr/local/apache1/bin
[...]
Thanks for using Apache. The Apache Group
http://www.apache.org/
[root@merc apache_1.3.29]#
Apache 2.x
Here is the transcript of the commands I used to install Apache 2. x on my server. The option --enable-mods-shared=most compiles all the standard modules, and leaves out the ones that are considered experimental:
- mod_mime_magic
- mod_cern_meta
- mod_user_track
- mod_unique_id
All the modules are compiled dynamically. Also, Apache’s main directory will be /usr/local/apache2/.
[root@merc apache_source]# tar xvzf httpd-2.0.48.tar.gz
httpd-2.0.48/
httpd-2.0.48/os/
httpd-2.0.48/os/os2/
httpd-2.0.48/os/os2/os.h
[...]
httpd-2.0.48/include/util_cfgtree.h
httpd-2.0.48/acconfig.h
[root@merc apache_source]# cd httpd-2.0.48
[root@merc httpd-2.0.48]# ./configure
--prefix=/usr/local/apache2 --enable-mods-shared=most
checking for chosen layout... Apache
checking for working mkdir -p... yes
[...]
config.status: creating build/rules.mk
config.status: creating include/ap_config_auto.h
config.status: executing default commands
[root@merc httpd-2.0.48]# make
Making all in srclib
make[1]: Entering directory `/root/apache
_source/httpd-2.0.48/srclib'
Making all in apr [...] config.status: creating include/ap_config_auto.h config.status: include/ap_config_auto.h is unchanged config.status: executing default commands
[root@merc httpd-2.0.48]# make install Making install in srclib make[1]: Entering directory `/root/apache_source/httpd-2.0.48/srclib' Making install in apr [...] mkdir /usr/local/apache2/manual Installing build system files make[1]: Leaving directory `/root/apache_source/httpd-2.0.48' [root@merc httpd-2.0.48]#
Apache is now installed.
This chapter is from Hardening Apache, by Tony Mobily. (Apress, 2004, ISBN: 1590593782). Check it out at your favorite bookstore today. Buy this book now.
|
Next: Running Apache and Testing it with Nikto >>
More Apache Articles
More By Apress Publishing