在 Ubuntu 上停止和启动 Apache 的命令和路径

Gen*_*nik 3 ubuntu apache-2.2

我一直在查找有关如何启动/停止 Apache 以及从哪个目录启动/停止 Apache 的不同文档,但没有找到正确的答案。

我正在使用 Ubuntu。

Sha*_*den 8

在典型操作中(作为服务运行,而不是故障排除或调试等),“正确”的方法是使用以下service命令:

service apache2 start
service apache2 stop
service apache2 restart
service apache2 reload (when you want to reload the config)
Run Code Online (Sandbox Code Playgroud)

运行它的目录无关紧要。供您参考,服务命令使用的脚本位于/etc/init.d; Apache 位于/etc/init.d/apache2. 所以/etc/init.d/apache2 start等等也会得到你想要的;但是 Ubuntu 10.10 和更新版本会要求您改用该service命令。

  • @Genadinik:默认情况下,日志位于 /var/log/apache2 中。 (2认同)