Synopsis
When acting in pass-through mode, apachectl
can take all the arguments available for the httpd
binary.
apachectl [httpd-argument]
When acting in SysV init mode, apachectl
takes simple, one-word commands, defined below.
apachectl command
Options
Only the SysV init-style options are defined here. Other arguments are defined on the httpd
manual page.
start
Start the Apache
httpd
daemon. Gives an error if it is already running. This is equivalent toapachectl -k start
.stop
Stops the Apache
httpd
daemon. This is equivalent toapachectl -k stop
.restart
Restarts the Apache
httpd
daemon. If the daemon is not running, it is started. This command automatically checks the configuration files as inconfigtest
before initiating the restart to make sure the daemon doesn't die. This is equivalent toapachectl -k restart
.fullstatus
Displays a full status report from
mod_status
. For this to work, you need to havemod_status
enabled on your server and a text-based browser such aslynx
available on your system. The URL used to access the status report can be set by editing theSTATUSURL
variable in the script.status
Displays a brief status report. Similar to the
fullstatus
option, except that the list of requests currently being served is omitted.graceful
Gracefully restarts the Apache
httpd
daemon. 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 as inconfigtest
before initiating the restart to make sure Apache doesn't die. This is equivalent toapachectl -k graceful
.graceful-stop
Gracefully stops the Apache
httpd
daemon. This differs from a normal stop in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This is equivalent toapachectl -k graceful-stop
.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. This is equivalent toapachectl -t
.
The following option was available in earlier versions but has been removed.
startssl
To start httpd
with SSL support, you should edit your configuration file to include the relevant directives and then use the normal apachectl start
.
需要重启Apache服务时,有多种方法:
1.apachectl -k graceful
优雅的重启,父进程将会等待子进程。
2.apachectl -k restart
立即重启
主要是graceful
---完美的重起--我推荐每次重起都用它不用restart--
它与restart的不同可以写一篇文章
--概括的说restart向apache主进程发送一个SIGHUP信号--而graceful发的是SIGUSER
1信号
--发送HUP信号给主进程将导致结束它的子进程, 就像TERM(stop)信号一样,但是主进程将不会终止. 它将重新读取配置文件, 并且重新打开所有的日志文件. 然后重新产生所有子进程并继续为点击操作提供服务.
而USR1 信号引起主进程处理并警告收到当前请求之后的子进程结束(或在它们不做任何服务时立刻结束). 主进程将重新读取它的配置文件并打开它的日志文件. 当每一个子进程结束后,主进程将使用配置信息产生一个新的子进程来立刻响应请求并为之服务.
--好象挺复杂的是吧
--主要是知道graceful要比restart 好就行了
查看apache是否起来 可以在你的shell里面输入 :
ps ax | grep apache
Apache参考文档:
http://httpd.apache.org/docs/2.2/stopping.html