在 CentOS 里,“Apache2”通常叫 httpd(Apache HTTP Server)。下面给你几种常见安装方式。
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
浏览器访问服务器 IP:
http://服务器IP
看到 Apache 测试页即成功。
sudo dnf install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
如果开了 firewalld:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
/etc/httpd/conf/httpd.conf/var/www/html/var/log/httpdsudo netstat -tunlp | grep :80
systemctl status httpd如果你说的是 Ubuntu 上的 apache2,或者想 编译安装最新版 Apache,也可以告诉我。