Debian / Ubuntu Linux 特定命令
在 Debian Linux 版本 7.x 或 Ubuntu Linux 版本 Ubuntu 14.10 或更早版本中,您可以使用以下 service 命令或 /etc/init.d/ 命令:
重启 Apache 2 web 服务器,请输入:
# /etc/init.d/apache2 restart
或者
$ sudo /etc/init.d/apache2 restart
或者
$ sudo service apache2 restart
停止 Apache 2 Web 服务器,请输入:
# /etc/init.d/apache2 stop
或者
$ sudo /etc/init.d/apache2 stop
或者
$ sudo service apache2 stop
启动 Apache 2 网络服务器,请输入:
# /etc/init.d/apache2 start
或者
$ sudo /etc/init.d/apache2 start
或者
$ sudo service apache2 start
关于Debian/Ubuntu Linux systemd用户的说明
在Debian Linux版本8.x+或Ubuntu Linux版本Ubuntu 15.04+或更高版本上使用以下命令:
启动命令
systemctl start apache2.service
停止命令
systemctl stop apache2.service
重启命令
systemctl restart apache2.service
CentOS/RHEL (Red Hat) Linux 版本 4.x/5.x/6.x 或更早的特定命令
开始
service httpd start
停止
service httpd stop
重新启动
service httpd restart
CentOS/RHEL(Red Hat)Linux 版本 7.x 或更新版本的特定命令
现在大多数现代发行版都使用 systemd,因此您需要使用以下命令:
启动命令
systemctl start httpd.service
停止指令
systemctl stop httpd.service
重启命令
systemctl restart httpd.service
在Linux/Unix上启动/停止/重新启动Apache的通用方法
语法如下(必须以root用户身份运行):
停止它
apachectl -k stop
重新启动它
apachectl -k restart
优雅重启它
apachectl -k graceful
开始吧
apachectl -f /path/to/your/httpd.conf
apachectl -f /usr/local/apache2/conf/httpd.conf
如果其他服务占用了80端口(例如:Skype),
请尝试以下代码:
sudo /etc/init.d/apache2 stop
代码如下:
sudo killall apache2
然后确保端口80上没有运行任何服务 代码:
sudo netstat -l|grep www
然后重新启动Apache代码:
sudo /etc/init.d/apache2 restart