在 CentOS 上启用 Apache2(通常称为 httpd)的步骤如下:
sudo yum install httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
如果服务正在运行,您将看到类似于以下的输出:
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since ...
http://your_server_ip_or_domain
您应该看到 Apache 的默认页面。
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
现在,您已经在 CentOS 上启用了 Apache2。如有需要,请根据您的需求进行配置。