我知道有三种重新启动 Apache 的方法:
sudo /usr/sbin/apachectl restart
sudo /etc/init.d/apache2 restart
service apache2 restart
每种方式的底层作用是什么?
我也尝试过service apache2 stop
在 Ubuntu 上使用,但由于某种原因它并没有停止服务器:localhost 仍然在我的桌面上提供服务。
答案1
service
和/或init.d
脚本与运行相同的脚本完全相同httpd
,主要用于stop
服务(re)start
httpd
,但apachectl
可以做更多(参见输出)。
apachectl
:
# apachectl
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
-S : a synonym for -t -D DUMP_VHOSTS
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t : run syntax check for config files
#