在 CentOS 上,Apache 的服务名通常是 httpd(不是 apache2,apache2 是 Debian/Ubuntu 的叫法)。
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd
sudo systemctl stop httpd
sudo systemctl restart httpd
sudo yum install httpd
(CentOS 8 可用 dnf)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
访问服务器 IP 即可看到 Apache 默认页面。
如果你是 CentOS 7 及以下 或用的 宝塔/面板,也可以告诉我,我给你对应命令。