- 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
Starting and Stopping the Server
At this point, you have your Apache server installed and configured the way you want it. It's time to start it up for the first time.
Starting the Server Manually
The Apache server, httpd, has a few command-line options you can use to set some defaults specifying where httpd will read its configuration directives. The Apache httpd executable understands the following options:
httpd [-D name][-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]
The -D option defines a name for use with <IfDefine name> directives in your configuration files. This allows you to conditionally include or exclude sections of your configuration when starting the server.
The -d option overrides the location of the ServerRoot directory. It sets the initial value of the ServerRoot variable (the directory where the Apache server is installed) to whichever path you specify. This default is usually read from the ServerRoot directive in httpd.conf.
The -f flag specifies the location of the main configuration file, conf/httpd.conf. It reads and executes the configuration commands found in ConfigurationFile on startup. If the ConfigurationFile is not an absolute path (it doesn't begin with a /), its location is assumed to be relative to the path specified in the ServerRoot directive in httpd.conf. By default, this value is set to ServerRoot /conf/httpd.conf.
The -v option prints the development version of the Apache server and terminates the process.
The -V option shows all of the settings that were in effect when the server was compiled.
The -h option prints the following usage information for the server:
Usage: httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled-in modules
-L : list available configuration directives
-S : show parsed settings (currently only vhost settings)
-t : run syntax check for config files (with docroot check)
-T : run syntax check for config files (without docroot check)
The -l option lists those modules that are compiled into your Apache server.
The -L option lists all of the configuration directives that are available with the modules that are compiled into your Apache server.
The -S option lists the virtual host settings for the server.
The -t option is extremely useful. It runs a syntax check on your configuration files. It's a good idea to run this check before restarting your server, once you have made changes to your configuration files. Performing such a test is especially important because an error in the configuration file might result in your server shutting down when you try to restart it.
The -T option is the same as the -t option, but it does not check the configured document roots.
The /etc/rc.d httpd Scripts
Red Hat Linux uses scripts in the /etc/rc.d directory to control the startup and shutdown of various services, including the Apache Web server. The main script installed for the Apache Web server is /etc/rc.d/init.d/httpd and it is shown in Listing 12.2.
You can use the following options to control the Web server:
- start—The system uses this option to start the Web server during boot up. You, as root, can also use this script to start the server.
- stop—The system uses this option to stop the server gracefully. You should use this script, rather than the kill command, to stop the server.
- reload—You can use this option to send the HUP signal to the httpd server to have it reread the configuration files after modification.
- restart—This option is a convenient way to stop and then immediately start the Web server. If the httpd server was not running, it will be started.
- condrestart—The same as the restart parameter, except that it will only restart the httpd server if it is actually running.
- status—This option indicates whether the server is running, and if it is, it provides the various PIDs for each instance of the server.
For example, to check on the current status, use the command
/etc/rc.d/init.d/httpd status
which prints the following for me:
httpd (pid 8643 8642 6510 6102 6101 6100 6099 6323 6322 6098 6097 6096 6095 362 6094 6093) is running...
This indicates that the Web server is running; in fact, there are 16 instances of the server currently running.
Example 12.2. /etc/rc.d/init.d/http
#!/bin/sh
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve # HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /etc/httpd/conf/access.conf
# config: /etc/httpd/conf/httpd.conf
# config: /etc/httpd/conf/srm.conf
# Source function library.
. /etc/rc.d/init.d/functions
# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon httpd
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /var/run/httpd.pid
;;
status)
status httpd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
killproc httpd -HUP
echo
;;
*)
echo "Usage: $0 { start|stop|restart|reload|status} "
exit 1
esac
exit 0
Configuration File Listings | Next Section

Account Sign In
View your cart