首页 > 其他 > 详细

centos 7 配置nginx

时间:2017-08-24 11:58:25      阅读:188      评论:0      收藏:0      [点我收藏+]

安装nginx:

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

rpm -ivh nginx.rpm

yum install nginx

 

启动nginx:

systemctl start nginx

激活服务:

systemctl enable nginx 

 

防火墙开放80端口:

firewall-cmd --zone=public --add-port=80/tcp --permanent

systemctl restart firewalld

 

修改nginx配置文件:

vi /etc/nginx/conf.d/default.conf 

内容如下:

server {
    listen 80;
    location / {
        proxy_pass http://localhost:9888;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

SELinux白名单:

yum install policycoreutils-python

sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx

sudo semodule -i mynginx.pp

重启nginx:

nginx –s reload

 

浏览器输入:http://192.168.136.138/ ,正常访问9888端口的网站

centos 7 配置nginx

原文:http://www.cnblogs.com/IWings/p/7422133.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!