Starting and Stopping the Web Server

On most systems, Apache is installed as a stand-alone server, continually running. As noted in Chapter 21, in the discussion of init scripts, your system automatically starts up the Web server daemon, invoking it whenever you start your system. A service script for the Web

Web Site Directories



Web site Web files


CGI program files


Apache Web server manual

Configuration Files



Directory-based configuration files; an .htaccess file holds directives to control access to files within the directory in which it is located


Directory for Apache Web server configuration files


Apache Web server configuration file


Directory holding module configuration files like ssl.conf for SSL and php.conf for PHP

Service Scripts



Service script for Web server daemon


Red Hat and Fedora configuration options for Web server daemon, as used by the httpd service script

Application and Module Files



Location of the Apache Web server program file and utilities


Apache Web server documentation


Location of Apache log files


Directory holding Apache modules


Directory holding Apache process IDs

Table 23-2 Apache Web Server Files and Directories (RPM Installation)

Table 23-2 Apache Web Server Files and Directories (RPM Installation)

server called httpd is in the /etc/rc.d/init.d directory. Symbolic links through which this script is run are located in corresponding runlevel directories. You will usually find the S85httpd link to /etc/rc.d/init.d/httpd in the runlevel 3 and 5 directories, /etc/rc.d/rc3.d and /etc/rc.d/rc5.d. You can use the chkconfig command or the System V Init Editor to set the runlevels at which the httpd server will start, creating links in appropriate runlevel directories. The following command will set up the Web server (httpd) to start up at runlevels 3 and 5 (see Chapters 21 and 27 for more details on runlevels):

# chkconfig --level 35 httpd on

You can also use the service command to start and stop the httpd server manually. This may be helpful when you are testing or modifying your server. The httpd script with the start option starts the server, the stop option stops it, and restart will restart it. Simply killing the Web process directly is not advisable.

# service httpd restart

The service command uses the /etc/sysconfig/httpd configuration file to set options for the httpd service script. Here you can specify such options as whether to use the worker or prefork Apache MPM modules.

Apache also provides a control tool called apachectl (Apache control) for managing your Web server. With apachectl, you can start, stop, and restart the server from the command line. The apachectl command takes several arguments: start to start the server, stop to stop it, restart to shut down and restart the server, and graceful to shut down and restart gracefully. In addition, you can use apachectl to check the syntax of your configuration files with the config argument. You can also use apachectl as a system service file for your server in the /etc/rc.d directory.

Remember, httpd is a script that calls the actual httpd daemon. You could call the daemon directly using its full pathname. This daemon has several options. The -d option enables you to specify a directory for the httpd program if it is different from the default directory. With the -f option, you can specify a configuration file different from httpd.conf. The -v option displays the version.

To check your Web server, start your Web browser and enter the Internet domain name address of your system. For the system, the user enters This should display the home page you placed in your Web root directory. A simple way to do this is to use Lynx, the command line Web browser. Start Lynx, and type g to open a line where you can enter a URL for your own system. Lynx displays your Web site's home page. Be sure to place an index.html file in the /var/www/html directory first.

Once you have your server running, you can check its performance with the ab benchmarking tool, also provided by Apache: ab shows you how many requests at a time your server can handle. Options include -v, which enables you to control the level of detail displayed, -n, which specifies the number of requests to handle (default is 1), and -t, which specifies a time limit.

NOTE Currently there is no support for running Apache under xinetd. In Apache 2.0, such support is determined by choosing an MPM module designed to run on xinetd.

Was this article helpful?

0 0

Post a comment