你如何重启Apache?
我从SLES切换到Ubuntu,现在我想重启我的本地服务器。 在SLES我用过:
rcapache2 restart
但这在某种程度上似乎不适用于Ubuntu。 🙁
我该如何重新启动Apache?
sudo service apache2 restart
方式是从Red Hat借来的,或者sudo restart apache2
以获得shiny的新Upstart方式。
您想要重新启动 Apache,还是要优雅地重新加载其配置?
每个人都在回答第一个问题; 你可以做第二个
sudo service apache2 reload
优雅地重装更快,并且没有停机时间。
有一点需要注意:如果您的apache配置文件包含错误(例如,在不存在的目录中配置日志文件),则服务器可以静默退出而不向控制台打印任何错误消息。 apache2ctl configtest
捕获了大多数其他错误,在使用apache2ctl graceful
进行实际重新加载之前, service apache2 reload
运行。
Ubuntu启动/停止服务(不仅仅是Apache)的推荐方法是使用start / stop / reload命令(它实际上是initctl程序的符号链接,是upstart的一部分)。
对于使用旧版/etc/init.d
脚本的服务,将使用正确的参数调用相应的脚本; 对于使用upstart基础结构的服务,将通过initctl向upstart守护程序发出相应的事件转换信号。
因此,要在Ubuntu上启动/停止/重新加载/重启apache,您可以使用:
sudo start apache2 sudo stop apache2 sudo reload apache2 sudo restart apache2
sudo /etc/init.d/apache2 restart
当然你可以换掉restart
stop
, start
和(我认为) reload
Ubuntu方式:
sudo service apache2 restart|stop|start
正如马吕斯所说,优雅应该用于重启:
sudo apache2ctl graceful
要么
sudo apache2ctl graceful-stop
优雅地停止Apache。
在重新启动/停止Web服务器之前,这些命令会一直等到所有网页请求都被提供,这样您的用户就不会获得半个网页。
首先,使用此命令检查您的状态
sudo service apache2 status
然后停止正在运行的服务
sudo service apache2 stop
然后使用此命令:
sudo /opt/lampp/lampp start
这个解决方案对我有用。
如果您在系统中安装Apache 2.4版本,要在本地系统上重新启动或停止Apache服务器,那么您应该运行以下命令
./apachectl start
或者您可以使用重启 ,也可以根据您的要求停止 。 这是经过测试的代码
您可以使用服务重新启动Apache
service apache2 restart
并且您可以使用它的所有function(停止 – 开始 – 重新加载)
如果你是root用户:(我认为在Ubuntu root中禁用,而不是使用’sudo’命令!)
$ /etc/init.d/apache stop $ /etc/init.d/apache start $ /etc/init.d/apache restart $ /etc/init.d/apache reload
(如果您使用的是a2iteite或a2dissite,则必须重新加载apache配置)