温馨提示×

centos下apache2如何启动

小樊
47
2026-09-21 06:08:36
栏目: 智能运维

在 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 stop httpd
sudo systemctl restart httpd

5. 防火墙放行(如有 firewalld)

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

6. 验证

浏览器访问:

http://服务器IP

看到 Apache 测试页即成功。


如果你是在 CentOS 上使用 Docker 或编译安装的 Apache,或者你确实看到的是 apache2 目录,可以告诉我具体情况,我帮你对应处理。

0 踩