在 CentOS 上“开启 Apache”通常包含 安装、启动、设置开机自启、开放防火墙 几个步骤。下面按常见版本说明。
sudo yum install httpd -y
(CentOS 8 也可用 dnf install httpd -y)
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
看到 active (running) 表示已开启。
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
http://服务器IP
看到 Apache 测试页即成功。
sudo yum install httpd -y
sudo service httpd start
sudo chkconfig httpd on
查看日志:
sudo journalctl -xe
# 或
sudo tail -f /var/log/httpd/error_log
Apache 默认端口是 80,确认未被 Nginx 等占用。
如果你是指:
可以告诉我你的 CentOS 版本和具体需求。