Installing Apache on Different Distributions

 < Free Open Study > 

This section discusses issues that arise when the Apache HTTP Server is installed on the three sample distributions. Generally, Apache's installation and startup processes are fairly self-contained (meaning that they don't rely much on other services being started first), so there isn't a great deal of variance across distributions. However, there are a few things that you should understand.

Installing Apache on Red Hat Linux

Installing Apache on Red Hat Linux is very straightforward using the techniques discussed in this chapter. There are, however, a couple things to be aware of relating to the Apache version and how to manage the software once it's installed.

Selecting the Correct Version

Red Hat Linux includes a package of the Apache HTTP Server. However, as of Red Hat Linux 7.3, this package is of an older version of Apache than the one discussed in this section. Generally, configuring the older Apache is largely the same (in the sense that it requires many of the same techniques), but there are some differences. If you choose to use Red Hat's standard distribution of Apache, be sure to consult and understand the Apache project's documentation for the older version.

Starting the Apache Server on Startup

One common need is to start up the Apache server automatically when the system boots up. As discussed in Chapter 4, this is accomplished on Red Hat Linux via the SysV model for system initialization scripts. This model is based on a "master" script that invokes a number of service-specific scripts, each of which adheres to a certain structure. These scripts are in turn responsible for starting, stopping, and restarting a particular service.


See Chapter 4 for more information about the SysV model.

The Apache HTTP Server includes a script program that automates the startup and shutdown of the server—it's the apachectl program mentioned earlier. This shell script can be passed the stop, start, and restart commands. These are the same commands used by SysV-compatible scripts, meaning that the apachectl program can be used to manage the Apache HTTP Server on a Red Hat Linux system.

To set this up, you need only create a symbolic link. The following command shows how this would be done if you've set up the server as discussed throughout this chapter:

 # ln -s /opt/apache/bin/apachectl /etc/rc.d/init.d/apache 

This command will configure Apache so that it can be started and stopped by the system—that is, the service command can be used as discussed in Chapter 4. However, Chapter 4 also describes the special naming and ordering of symbolic links that actually determines whether and when a service gets started when the system boots up. Simply making the preceding symbolic link won't actually cause Apache to be started when the system boots.


See Chapter 4 for more information about the use of symbolic links in the SysV init scripts model.

There are two options to make Apache start on system boot. One is to manage the necessary symbolic links by hand (which is discussed in Chapter 4), and the other is to make the apachectl script compatible with Red Hat's chkconfig command, which can then be used to manage the script.

Making apachectl Compatible with chkconfig

In order to properly integrate Apache with the tools Red Hat provides for managing system services, the apachectl script needs to be integrated with Red Hat's service command (which was discussed in the previous section) as well as the chkconfig command. Both of these commands are discussed in detail in Chapter 4, and you must read that chapter to get the full details on the material discussed in this section.

Making a script compatible with chkconfig means adding a comment to the script that contains information used by chkconfig to configure the service. The following lines can be added to the apachectl script—they contain the required information:

 # chkconfig: 345 99 99 # description: The Apache HTTP Server 

Those lines will cause apachectl to be (by default) configured to run on runlevels 3 through 5, with priority 99 for both startup and shutdown (since Apache has no dependence on other services being run). Once you've made this change to the apachectl script, you can activate it by running the command chkconfig –add apache; after that, you'll be able to manage Apache's startup status normally, using the tools and techniques described in the section "System Startup Scripts" in Chapter 4.

Some administrators may not like the idea of modifying a script provided by Apache, for very good reason: If Apache is upgraded, this change will have to be made to the upgraded apachectl script as well. If this is a concern, it may be worthwhile to write a very simple shell script (similar to Listing 8-1 from Chapter 8) that contains the chkconfig information and simply calls the apachectl script. This way, the service command and other system tools will use the custom script, and the apachectl script won't have to be modified. Some administrators may prefer this option.

Installing Apache on Slackware Linux

As with Red Hat Linux, Apache is easy to set up on Slackware Linux. Slackware Linux 8.0 also contains a package for Apache, but again, like Red Hat it's an older version than the one discussed in this chapter. Configuring Apache to be started by Slackware Linux is very simple.

As discussed in the section "System Startup Scripts" in Chapter 5, Slackware Linux uses the BSD model of system startup scripts, but it also provides a minimal SysV-compatible "hook" for convenience. Configuring Apache to be started when Slackware Linux boots is as simple as creating a symbolic link in the appropriate directory, such as with the following command:

 # ln -s /opt/apache/bin/apachectl /etc/rc.d 

This command is very similar to the equivalent command provided for Red Hat in the previous section. However, again demonstrating Slackware's primary goal of simplicity, there's nothing more to it than that. With the preceding command, Apache will be started each time the system starts up.

Installing Apache on Debian GNU/Linux

Like Red Hat Linux and Slackware Linux, Debian GNU/Linux includes a prebuilt package for Apache, but again it's the older version of the software. If you choose to use the material discussed in this chapter to build and install your own installation, you'll find that most of the material earlier on Red Hat Linux also applies to Debian GNU/Linux.

That is, since the two distributions both use the SysV model for their init scripts, the process is very similar. However, you'll have to use Debian's tools for managing the init scripts for your system's runlevels, as discussed in the section "Working with Debian's Tools" in Chapter 6. Additionally, you'll probably want to create that separate script that simply invokes the apachectl script (as mentioned earlier in the context of Red Hat Linux).

 < Free Open Study > 

Tuning and Customizing a Linux System
Tuning and Customizing a Linux System
ISBN: 1893115275
EAN: 2147483647
Year: 2002
Pages: 159 © 2008-2017.
If you may any questions please contact us: