在 Ubuntu 上重启 Apache 服务,最常用、最推荐的方法是使用 systemctl(适用于 Ubuntu 16.04 及以后版本)。
sudo systemctl restart apache2
# 启动 Apache
sudo systemctl start apache2
# 停止 Apache
sudo systemctl stop apache2
# 重启 Apache
sudo systemctl restart apache2
# 重新加载配置(不中断服务,最常用)
sudo systemctl reload apache2
# 查看运行状态
sudo systemctl status apache2
sudo service apache2 restart
systemctl status apache2
或
curl -I 127.0.0.1
如果只是修改了配置文件(如虚拟主机),优先使用 reload:
sudo systemctl reload apache2
如果你遇到报错或重启失败,可以把错误信息贴出来,我可以帮你具体分析。