温馨提示×

apache2在centos怎启动

小樊
40
2026-09-30 03:10:08
栏目: 智能运维

在 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. 如果还没安装

sudo yum install httpd

(CentOS 8 可用 dnf)

6. 防火墙放行(如果需要外网访问)

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

访问服务器 IP 即可看到 Apache 默认页面。

如果你是 CentOS 7 及以下 或用的 宝塔/面板,也可以告诉我,我给你对应命令。

0 踩