(learning php / PHP教程)第026讲 apache服务器使用及配置① 启动和停止 端口配置
目录:
Apache是开放源代码和跨平台的HTTP服务器。 它具有强大的功能,并且可以通过各种模块进一步扩展。
使用Apache Web服务器时,启动,停止以及重新启动/重新加载是最常见的任务。 在Linux发行版中,用于管理Apache服务的命令是不同的。
最近的大多数Linux发行版都使用SystemD作为默认的初始化系统和服务管理器。 较早的发行版基于SysVinit并使用初始化脚本来管理服务。 另一个区别是服务的名称。 在Ubuntu和Debian中,Apache服务名为
apache2
,而在基于Red Hat的系统(如CentOS)中,服务的名称为
httpd
。
在本指南中,我们将说明如何在最流行的Linux发行版中启动,停止和重新启动Apache。
在你开始之前
这些说明假定您以root用户或具有sudo特权的用户身份登录。
SystemD服务单元和SysVinit脚本都采用以下参数来管理Apache服务:
-
start:启动Apache服务。stop:终止Apache服务。restart:停止然后再启动Apache服务。reload:正常重启Apache服务。 重新加载时,主Apache进程将关闭子进程,加载新配置,然后启动新的子进程。status:显示服务状态。
在Ubuntu和Debian上启动,停止和重新启动Apache
SystemD是最新Ubuntu(18.04,16.04)和Debian(10,9)版本的系统和服务管理器。
执行以下命令以启动Apache服务:
sudo systemctl start apache2
执行以下命令以停止Apache服务:
sudo systemctl stop apache2
每当您更改Apache配置时,都需要重新启动服务器进程。 执行以下命令以重新启动Apache服务:
sudo systemctl restart apache2
较早的(EOLed)版本的Ubuntu或Debian使用init.d脚本来启动,停止和重新启动Apache守护程序:
sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart
在RHEL / CentOS上启动,停止和重新启动Apache
Systemd是RHEL / CentOS 7和8的系统和服务管理器。
启动Apache服务:
sudo systemctl start
停止Apache服务:
sudo systemctl stop
重新启动Apache服务:
sudo systemctl restart
如果您具有CentOS 6(或更早版本),请使用以下命令来启动,停止和重新启动Apache守护程序:
sudo service httpd start
sudo service httpd stop
sudo service httpd restart
结论
在本指南中,我们向您展示了如何在各种Linux系统上启动,停止和重新启动Apache Web服务器。
apache终端






