📅  最后修改于: 2023-12-03 15:42:05.316000             🧑  作者: Mango
当我们在 Ubuntu 系统下使用 Apache 服务器时,有时需要重启 Apache 以使配置更改生效。在本文中,我们将讨论如何在 Ubuntu 系统上重启 Apache 服务器。
在执行任何操作之前,必须先确认 Apache 服务器是否已安装和运行。可以使用以下命令检查 Apache 服务器是否在运行:
systemctl status apache2
如果 Apache 服务器正在运行,则将收到以下输出:
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-12-01 15:50:47 UTC; 1h 21min ago
Process: 4592 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 4604 (apache2)
Tasks: 11 (limit: 2337)
Memory: 22.7M
CGroup: /system.slice/apache2.service
├─4604 /usr/sbin/apache2 -k start
├─4605 /usr/sbin/apache2 -k start
└─4606 /usr/sbin/apache2 -k start
如果 Apache 服务器未启动,则将收到以下输出:
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2021-12-01 14:34:50 UTC; 2h 37min ago
Process: 4344 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 4412 (code=exited, status=0/SUCCESS)
如果 Apache 服务器未安装,则将提示安装 Apache 服务器。
在 Ubuntu 系统中,可以使用以下命令重启 Apache 服务器:
sudo systemctl restart apache2
执行此命令后,Apache 服务器将停止并重新启动。您可以使用以下命令检查服务器的状态:
systemctl status apache2
在本文中,我们讨论了如何在 Ubuntu 系统上重启 Apache 服务器。在执行任何操作之前,必须确认 Apache 服务器是否已安装和在运行。通过使用上述命令,可以轻松重启 Apache 服务器以使配置更改生效。