在 CentOS 上配置 Apache(httpd) 通常只需要几步即可完成,下面以 CentOS 7 / 8 / Stream 为例,按最常用流程说明(约 6 步):
sudo yum install httpd -y
(CentOS 8 可用 dnf:sudo dnf install httpd -y)
sudo systemctl start httpd
sudo systemctl enable httpd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
浏览器访问:
http://服务器IP
看到 Apache 测试页 即成功。
/var/www/html/
/etc/httpd/conf/httpd.conf
修改后重启:
sudo systemctl restart httpd
yum install httpd -y
systemctl start httpd
systemctl enable httpd
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
如果你是 CentOS 6、配置虚拟主机、HTTPS(SSL) 或 LNMP 环境,可以告诉我,我可以给你更具体的配置步骤。