1.9. Restarting Your Web Server

Problem

You need to restart the HTTP daemon that processes requests for web pages on your server.

Solution

At the command-line prompt for your server, issue the apachectl graceful command, or the appropriate restart command for your web server.

Discussion

Restarting your web server has come up in several of the topics covered in this chapter. When you modify the configuration file for Apache, you have to restart it for any changes to take effect.

Basic webhosting accounts usually share Apache server processes with other web sites, so if that's the case with your web site, your provider may not want or allow you to restart Apache. Web designers with higher priced virtual server accounts, or accounts running on a dedicated server, have Apache all to themselves and usually can issue the commands for stopping and starting it as needed.

Later versions for Apache install with a control script called apachectl. With it, you can start, stop, and restart the HTTP daemon on your dedicated server or "virtual server" account.

Finding the script

You should be able to use apachectl at the command-line prompt to your web server by typing its name followed by a space and stop, start, or graceful. If that does not work, you will have to specify the full path to the script. To locate the script on your server, use one of these commands:

	find / -name apachectl

or:

	which apachectl
Stopping and starting Apache

The results of the commands apachectl stop and apachectl start are self-evident.

Warning

The stop command immediately turns off the server, cutting off connections that may still be in the process of downloading pages from your web site.

Gracefully restarting Apache

A better way to restart Apache after a change to the configuration file is with the graceful argument to apachectl. In this case, Apache leaves current connections to browsers open and starts applying the changed settings to new connections.

See Also

The Apache Software Foundation web site has more information about stopping and starting the Apache web server on the manual page for apachectl at http://httpd.apache.org/docs/programs/apachectl.html and a guide to restarting Apache at http://httpd.apache.org/docs/stopping.html.

Get Web Site Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.