欢迎光临小鱼网个人网站!

登录/注册
centos7安装nginx修改默认端口

1.添加源

    sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.安装Nginx通过yum search nginx看看是否已经添加源成功。如果成功则执行下列命令安装Nginx

    sudo yum install -y nginx

image.png

3.启动Nginx并设置开机自动运行:

sudo systemctl start nginx.service

sudo systemctl enable nginx.service

4.查看nginx状态

systemctl status nginx.service

如果端口未开启运行

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

sudo firewall-cmd –reload

5.修改nginx默认端口

vim /etc/nginx/conf.d/default.conf

image.png

改完之后开放自己所修改的端口,在重启下nginx:

firewall-cmd –zone=public –add-port=8080/tcp –permanent

firewall-cmd –reload

6.安装semanage再安装policycoreutils软件包。

yum install semanage

如果提示No package semanage available执行

yum provides semanage

以上命令执行成功后,再执行:

yum -y install policycoreutils-python.x86_64

再安装policycoreutils软件包

yum install policycoreutils

安装完成之后执行如下命令:

semanage port -a -t http_port_t -p tcp 8080

semanage port -m -t http_port_t -p tcp 8080

重启一下nginx :systemctl restart nginx.service


Copyright © www.xyubing.com All Rights Reserved. 备案号:蜀ICP备19023461号-1

免责声明:本站部分资源搜集整理于互联网或者网友提供,仅供学习与交流使用,如果不小心侵犯到你的权益,请及时联系我们删除该资源。