温馨提示×

centos上apache2如何启动

小樊
34
2026-10-17 14:30:30
栏目: 智能运维

在 CentOS 上,Apache 的软件包名是 httpd,而不是 apache2(apache2 是 Debian/Ubuntu 的叫法)。

1. 启动 Apache(httpd)

sudo systemctl start httpd

2. 设置开机自启

sudo systemctl enable httpd

3. 查看运行状态

sudo systemctl status httpd

4. 重启 / 停止

sudo systemctl restart httpd
sudo systemctl stop httpd

5. 防火墙放行(如果开启了 firewalld)

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

6. 验证

浏览器访问服务器 IP:

http://服务器IP

看到 Apache 测试页即成功。


如果你是在 CentOS 上使用 Docker / 编译安装的 Apache,或者你确认系统里真的有 apache2 命令,也可以告诉我,我给你对应的启动方式。

0 踩