在 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 firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
浏览器访问:
http://服务器IP
看到 Apache 测试页即成功。
如果你是在 CentOS 上使用 Docker 或编译安装的 Apache,或者你确实看到的是 apache2 目录,可以告诉我具体情况,我帮你对应处理。