cat /etc/redhat-release     //查看系统版本

Centos 8开启Apache服务

 sudo systemctl status firewalld      //检查防火墙状态

 

Centos 8开启Apache服务

安装Apache(在基于RHEL的发行版中,Apache软件包和服务称为httpd)。

yum install httpd

Centos 8开启Apache服务

启用Apache服务,并使其在系统启动时启动。

systemctl start httpd

systemctl enable httpd

Centos 8开启Apache服务

检查Apache运行状态。

systemctl status httpd

Centos 8开启Apache服务

还可以检查Web服务器的版本,以确保已正确安装。

httpd -v

Centos 8开启Apache服务

测试Apache Web服务器。

在浏览器中输入http://127.0.0.1,如果出现测试页,说明安装正确。也可以使用curl 127.0.0.1:80进行测试

Centos 8开启Apache服务

默认情况下,CentOS使用firewalld作为守护程序运行的防火墙,并为其提供基本安全性。因此,尽管已经在本机上可以访问Web服务,但很可能在远程计算机上无法访问。为了接受HTTP和HTTPS连接,还需打开服务器上的80和443端口。

sudo firewall-cmd --permanent --zone=public --add-service=http

sudo firewall-cmd --permanent --zone=public --add-service=https

sudo firewall-cmd --reload

 

Centos 8开启Apache服务

验证防火墙配置是否正确。

在远程计算机浏览器中输入http://IP,如果出现测试页,说明防火墙配置正确。


祝这世界继续热闹,祝我仍是我。