使用apachectl和apache2重新启动Apache有什么区别?


9

我知道重启Apache的三种方法:

sudo /usr/sbin/apachectl restart

sudo /etc/init.d/apache2 restart

service apache2 restart

每种方式在下面做什么?

我也尝试service apache2 stop在Ubuntu上使用,但是由于某些原因它不会停止服务器:本地主机仍在我的桌面上运行。

Answers:


10

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
# 

好的原因,我问s是因为我使用了sudo / usr / sbin / apachectl restart,我的所有django静态文件现在都出现404错误,认为与服务器重启方法有关
曼哈顿博士

@DrManhattan更可能是您更改了配置文件(也许是通过重写)。您之前没有注意到它,因为更改在重新启动服务后才生效。
kojow7
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.