默认地,Apache使用80端口,而Nginx也是使用80端口。为减少防火墙开放端口,同时也便于用户识别和输入,通常只开放默认80端口。所以,可以通过Nginx来反向代理Apache。但是,在修改Apache端口时却有些坑。
Apache/httpd端口修改
1. 修改/etc/httpd/conf/httpd.conf 文件
#把默认80改为你设置的端口,我设置端口为8080
Listen 8080
2.重新加载配置文件
service httpd reload
此时,却发现Apache无法正常启用。搜索了下,原来是 SELinux 安全机制的作用,对于非标准端口有限制。网上也有很多解决方案。
方案1:临时解决方案
参考文章:centos6.5查看SELinux状态及关闭 -- https://blog.youkuaiyun.com/weixin_43976137/article/details/100633062
1. 查看SELinux 状态
[dotnba@centos8 selinux]$ sestatus
SELinux status: enabled
SELinuxfs mount: