Ubuntu 系統通過 apt-get install apache2 安裝 Apache 後,執行 service httpd restart 或 pkill -1 httpd 均無效,必須用 /etc/init.d/apache2 restart 才能重啟服務。
apache2,而非 RHEL/CentOS 習慣的 httpdsystemd,service 命令兼容轉發到 systemctl,但舊版腳本可能未正確適配systemctl list-units | grep apache
# 或
service --status-all | grep apache
典型輸出:apache2.service
sudo systemctl restart apache2 # 重啟
sudo systemctl reload apache2 # 平滑重載配置
sudo systemctl status apache2 # 查看狀態
sudo service apache2 restart # 實際調用 systemctl
sudo /etc/init.d/apache2 restart # 直接調用 init 腳本
pkill -HUP -f apache2 # 發送 SIGHUP 觸發平滑重載
pkill -TERM -f apache2 # 強制終止
/etc/apache2//etc/httpd/systemctl,避免混用 service/pkill 導致狀態不一致