httpd.md 977 Bytes

安装httpd组件及配置

安装httpd,配置httpd端口,配置防火墙规则

//------------ 安装httpd及配置 -------------//
// 查看是否安装了httpd
rpm -qa | grep httpd
// 安装epel-release
yum -y install epel-release
// 安装httpd
yum -y install httpd
// 启动服务,设置开机自启
systemctl enable httpd
systemctl start httpd
// 查看服务列表
systemctl --type=service | grep httpd
// 查看端口占用(默认80)
netstat -tunlp | grep httpd
// 修改默认端口
vi /etc/httpd/conf/httpd.conf
定位到listener段修改端口
// 配置httpd的防火墙规则
cp /usr/lib/firewalld/serviced/http.xml /etc/firewalld/services/my_http.xml
vi /etc/firewalld/services/my_http.xml
将里面的short改成my_http,port改成8888
// 防火墙添加自定义服务,重新载入规则,显示服务
firewall-cmd --add-service=my_http --permanent
firewall-cmd --reload
firewall-cmd --list-service
// http测试
curl -I 127.0.0.1:8888