在 CentOS 上启动 Apache(httpd) 可按下面步骤操作(适用于 CentOS 7/8/Stream,使用 systemd):
sudo yum install -y httpd
(CentOS 8 / Stream 可用 dnf 代替 yum)
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
如果系统启用了 firewalld:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
浏览器访问服务器 IP:
http://服务器IP
看到 Apache HTTP Server Test Page 即成功。
sudo netstat -tulnp | grep :80
/var/www/html 目录权限正确sudo setenforce 0
如果你用的是 CentOS 6(init.d) 或 Docker / 云服务器,可以告诉我,我可以给你对应的启动方式。