在 Ubuntu 上重启 Apache2 通常有几种方式,最常用的是使用 systemctl 或 service 命令。
sudo systemctl restart apache2
sudo service apache2 restart
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl reload apache2
sudo systemctl status apache2
sudo 权限sudo tail -n 50 /var/log/apache2/error.log
sudo apache2ctl configtest
如果你是用的不是 apache2 而是其他名称(极少情况),可以先用:
systemctl list-units --type=service | grep apache
确认服务名。