Tutorials
How to Restart Apache
If you have made changes to the Apache configuration file httpd.conf on you need to reload the Apache service for the changes to take effect. From the command line you do this with the apachectl command. The exact location of this command varies on the Unix or Linux variant you are using (eg Fedora, OSX, FreeBSD, Slackware, Mandrake, SUSE) and the compile time settings, but typically it is accesible at /usr/sbin/apachectl . An example of restarting Apache gracefully is shown below:

/usr/sbin/apachectl graceful

Note that you will either need to be running as root or use the "sudo" command in order to run this command.

If Apache is not already running it will be started. If it is already running then it will reload with the new changes but will not abort active connections, meaning that anyone who is in the middle of downloading something will continue to be able to download it.

Before restarting the Apache service a check will be done on the configuration files to ensure they are valid. If there is an error in them the error will be displayed and the Apache service will continue running using the old settings. You need to correct your settings before attempting to restart again.

You can also just check the settings without restarting Apache like so:

/usr/sbin/apachectl configtest

This will check the httpd.conf file and report whether the syntax of the file is valid or not. A list of errors will be displayed including the line numbers if there are any. This makes it easy to isolate any problems.

The following are all the available options that can be passed to the apachectl command. This text is from the apachectl man page.

apachectl start: Start the Apache daemon. Gives an error if it is already running.

apachectl stop: Stops the Apache daemon.

apachectl restart: Restarts the Apache daemon by sending it a SIGHUP. If the daemon is not running, it is started. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.

fullstatus: Displays a full status report from mod_status. For this to work, you need to have mod_status enabled on your server and a text-based browser such as lynx available on your system. The URL used to access the status report can be set by editing the STATUSURL variable in the script.

apachectl status: Displays a brief status report. Similar to the fullstatus option, except that the list of requests currently being served is omitted.

apachectl graceful: Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.

apachectl configtest: Run a configuration file syntax test. It parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error.

apachectl help: Displays a short help message.
Apache
Restarting Apache
Apache HTTP Server