If you have made changes to the Apache configuration file httpd.conf or one of the other included configuration files such as the vhosts.d files, 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.
Update March 19th 2007
I wrote this article originally for Apache 1.3 and when I was using Gentoo Linux and OSX to serve pages with Apache. On my current openSUSE machines which run Apache 2.2 there is no longer an apachectl program. Instead of the above command you can run the following very similar command and options instead:
/etc/init.d/apache2 start|stop|reload|restart|configtest
Running /etc/init.d/apache2
on its own outputs a help message to detail the various options as listed below:
start - start httpd
startssl - start httpd with -DSSL
stop - stop httpd (sendign SIGTERM to parent)
try-restart - stop httpd and if this succeeds (i.e. if it was running before), start it again.
status - check whether httpd is running
restart - stop httpd if running; start httpd
reload|graceful - do a graceful restart by sending a SIGUSR1 or start if not running
configtest - do a configuration syntax test
extreme-configtest - try to run httpd as nobody (detects more errors by actually loading the configuration, but cannot read SSL certificates)
probe - probe for the necessity of a reload, give out the argument which is required for a reload. (by comparing conf files with pidfile timestamp)
full-server-status - dump a full status screen; requires lynx or w3m and mod_status enabled
server-status - dump a short status screen; requires lynx or w3m and mod_status enabled
help - this screen
Tidak ada komentar:
Posting Komentar