CentOS快速部署Apache服务-配置防火墙
目录
配置Apache服务
配置防火墙
配置Apache服务
- 将服务器当前的用户切换至
root
用户,便于后续配置应用。sudo su root
- 运行以下命令,安装Apache服务。
yum install -y httpd
- 依次运行以下命令,启动Apache服务,并将服务设置为开机自启动。
systemctl start httpd
- 启动Apache服务:
systemctl start httpd
- 将Apache服务设置为开机自启动:
systemctl enable httpd
- 运行以下命令,查看Apache服务的运行状态。
systemctl status httpd
配置防火墙
- 查看80端口占用情况
netstat -an|grep :80
-
检查Apache是否已经安装了开机自启
systemctl list-unit-files | grep httpd
-
查看防火墙状态
systemctl status firewalld
-
查看防火墙端口开放情况
firewall-cmd --list-ports
-
防火墙开启centos7的80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
-
重启防火墙
firewall-cmd --reload