温馨提示×

centos apache2怎样启动

小樊
47
2026-09-06 02:55:28
栏目: 智能运维

CentOS 上,Apache 的服务名通常是 httpd(不是 apache2,apache2 是 Debian/Ubuntu 的叫法)。

1. 启动 Apache

sudo systemctl start httpd

2. 设置开机自启

sudo systemctl enable httpd

3. 查看运行状态

sudo systemctl status httpd

4. 停止 / 重启

sudo systemctl stop httpd
sudo systemctl restart httpd

5. 如果还没安装

sudo yum install httpd

(CentOS 8 可用 dnf

6. 防火墙放行(可选)

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

然后浏览器访问服务器 IP 即可看到 Apache 测试页。

如果你是 CentOS 上的 Docker / 非 systemd 环境,或用的是 apache2 包,可以告诉我具体环境,我给你对应方法。

0