在 Ubuntu 上重启 Apache2 服务,常用以下几种方式(需要 sudo 权限):
sudo systemctl restart apache2
sudo service apache2 restart
sudo /etc/init.d/apache2 restart
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl reload apache2
sudo systemctl status apache2
如果你是修改了配置文件,建议先测试配置是否正确:
sudo apache2ctl configtest
显示 Syntax OK 后再重启或 reload。