在 CentOS 上启动 Apache(通常叫 httpd 服务),可以按下面步骤操作:
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
sudo service httpd start
开机自启:
sudo chkconfig httpd on
如果没有安装:
sudo yum install httpd
(CentOS 8 可用 dnf)
如果无法访问网页,可能是防火墙原因:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
浏览器访问:
http://服务器IP
看到 Apache 测试页面 即成功。
如果你用的是 CentOS Stream / 特定版本 / 源码安装 Apache,可以告诉我,我给你更精确的命令。