- Table of Contents
- Copyright
- About the Lead Authors
- About the Contributing Authors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- I. Red Hat Linux Installation and User Services
- Chapter 1. Introduction to Red Hat Linux
- Chapter 2. Installation of Your Red Hat System
- Chapter 3. LILO and Other Boot Managers
- Chapter 4. Configuring the X Window System, Version 11
- Chapter 5. Window Managers
- Chapter 6. Connecting to the Internet
- Chapter 7. IRC, ICQ, and Chat Clients
- Chapter 8. Using Multimedia and Graphics Clients
- II. Configuring Services
- Chapter 9. System Startup and Shutdown
- Chapter 10. SMTP and Protocols
- Chapter 11. FTP
- Chapter 12. Apache Server
- Chapter 13. Internet News
- Chapter 14. Domain Name Service and Dynamic Host Configuration Protocol
- Chapter 15. NIS: Network Information Service
- Chapter 16. NFS: Network Filesystem
- Chapter 17. Samba
- III. System Administration and Management
- Chapter 18. Linux Filesystems, Disks, and Other Devices
- Chapter 19. Printing with Linux
- Chapter 20. TCP/IP Network Management
- Chapter 21. Linux System Administration
- Chapter 22. Backup and Restore
- Chapter 23. System Security
- IV. Red Hat Development and Productivity
- Chapter 24. Linux C/C++ Programming Tools
- Chapter 25. Shell Scripting
- Chapter 26. Automating Tasks
- Chapter 27. Configuring and Building Kernels
- Chapter 28. Emulators, Tools, and Window Clients
- V. Appendixes
- A. The Linux Documentation Project
- B. Top Linux Commands and Utilities
- C. The GNU General Public License
- D. Red Hat Linux RPM Package Listings
Server Installation
You can install Apache from RPMs or by building the source code yourself. The Apache source builds on just about any UNIX-like operating system, and also on Win32.
If you are about to install a new version of Apache, it is probably a good idea to shut down the old server. Even if it is unlikely that the old server will interfere with the installation procedure, shutting it down ensures that there will be no problems. If you do not know how to stop Apache, look at the section Starting and Stopping the Server later in this chapter.
Installing from the RPM
You can find the Apache RPM either on the Red Hat Linux installation media, on the Red Hat FTP server, or one of its many mirror sites. You will want to check the updates.redhat.com FTP site (or one of the mirrors) as often as possible. In the directory corresponding to your Red Hat version you will from time to time find updates for Apache. These can be important updates that fix bugs or security breaches. When an updated version comes out, you will want to install it as quickly as possible in order to be secure.
After you have obtained an Apache RPM, you can install it with the command-line rpm tool by typing the following:
rpm -Uvh latest_apache.rpm
where latest_apache.rpm is the name of the latest Apache RPM.
For more information on installing packages with RPM, see Chapter 21, "Linux System Administration."
The Apache RPM installs files in the following directories:
- /etc/httpd/conf— This directory contains all the Apache configuration files, which include access.conf, httpd.conf, and srm.conf. See the section on configuration files later in this chapter.
- /etc/rc.d/— The tree under this directory contains the system startup scripts. The Apache RPM installs a complete set for the Web server. These scripts, which you can use to start and stop the server from the command line, will also automatically start and stop the server when the computer is halted, started, or rebooted. See Chapter 9, "System Startup and Shutdown," for information about these startup scripts.
- /var/www—The RPM installs the default server icons, CGI programs, and HTML files in this location. If you want to keep Web content elsewhere, you can do so by making the appropriate changes in the server configuration files.
- /var/www/html/manual/— If you have installed the apache-manual RPM, you will find a copy of the Apache documentation in HTML format here. You can access it with a Web browser by going to http://localhost/manual/.
- /usr/share/man— The RPM contains manual pages, which are placed in this directory.
- /usr/sbin— The executable programs are placed in this directory. This includes the server executable itself, as well as various utilities.
- /usr/bin— Some of the utilities from the Apache package are placed here—for example, the htpasswd program, which is used for generating authentication password files.
- /var/log/http— The server log files are placed in this directory. By default, there are two log files—access_log and error_log—but you can define any number of custom logs containing a variety of information. See the section on logging later in this chapter.
- /usr/src/redhat/SOURCES/— This directory contains a tar archive containing the source code for Apache, and in some cases patches for the source. You must have installed the Apache SRPM for these files to be created.
When Apache is being run, it will also create files in the following directories:
- /var/run/lock—The startup script adds a lock file, called httpd.
- /var/run— Apache will create a file, httpd.pid, containing the process ID of Apache's parent process.
Building the Source Yourself
There are several ways in which you can obtain the source code for Apache. The Red Hat distribution has SRPMs containing the source of Apache, which sometimes include patches to make it work better with Red Hat's distribution. The most up-to-date versionsare found at ftp://updates.redhat.com. When you install one of these SRPMs, a tar archive containing the Apache source will be created in /usr/src/redhat/SOURCES/. You can also download the source directly from http://www.apache.org/.
Once you have a tar file, you will need to unroll it in a temporary directory somewhere nice, like /tmp. This will create a directory called apache_ version_number, where version_number is the version that you have downloaded (for example, apache_1.3.12).
There are two ways to compile the source—the old, familiar way (at least, to those of us who have been using Apache for many years) and the new, easy way.
The Easy Way
To build Apache the easy way, just run the ./configure in the directory just created. You can provide it with a --prefix argument to install in a directory other than the default, which is /usr/local/apache/.
./configure --prefix=/preferred/directory/
This will create a file called Configuration in the src/ subdirectory. It also generates the makefile that will be used to compile the server code.
Once this step is done, type make to compile the server code. After the compilation is completed type make install to install the server. You can now configure the server via the configuration files. See the section Runtime Server Configuration Settings for more information.
The Advanced Way
If you want to do things the old-fashioned way, or you just want more control over the way that your server is built, follow these steps:
- In the source directory, copy the file Configuration.tmpl to Configuration and open up Configuration with your favorite editor.
- Modify the compiler flags if, and only if, you know what you're doing. Uncomment those modules that you would like included, comment out modules that you don't want, or add lines for custom modules that you have written or acquired elsewhere.
- Run the Configure script to create the Makefile.
- Finally, compile and install the server with make and make install.
File Locations After Manual Installation
As of version 1.3.4, all of the files are placed in various subdirectories of /usr/local/apache (or whatever directory you specified with the --prefix parameter). Before version 1.3.4, files were placed in /usr/local/etc/httpd.
The following is a list of those directories that are used by Apache, as well as brief comments on their usage.
- /usr/local/apache/conf—This directory contains all the Apache configuration files, which include access.conf, httpd.conf, and srm.conf. See the section on configuration files later in this chapter.
- /usr/local/apache— The cgi-bin, icons, and htdocs subdirectories contain the CGI programs, standard icons, and default HTML documents, respectively.
- /usr/local/apache/bin— The executable programs are placed in this directory.
- /usr/local/apache/logs— The server log files are placed in this directory. By default, there are two log files—access_log and error_log—but you can define any number of custom logs containing a variety of information. See the section on logging later in this chapter.
Runtime Server Configuration Settings | Next Section

Account Sign In
View your cart