代码改变世界

centos nginx

2017-11-22 15:30  xchit  阅读(262)  评论(0编辑  收藏  举报

centos 下载地址:http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso

第一步设置网卡:

1. cd /etc/sysconfig

2. cd network-scripts

3. vi ifcfg-ens33

4.修改ONBOOT=yes   【insert修改,:wq退出保存】

5.重启网卡 service network restart

 6.安装ifconfig命令  sudo yum install net-tools

7.输入ifconfig查看机器IP

第二步下载putty链接工具 https://www.ssh.com/a/putty-64bit-0.70-installer.msi

第三步安装nginx  https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7

1. sudo yum install epel-release

2. sudo yum install nginx

3.sudo systemctl start nginx

开启防火墙

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

sudo firewall-cmd --permanent --zone=public --add-service=https

sudo firewall-cmd --reload

备注:鼠标右键复制
现在可以通过ip访问到nginx主页了 第四步安装asp.net core https://www.microsoft.com/net/learn/get-started/linuxcentos


cd /etc/nginx

touch netcore.conf

nginx -s reload

systemctl nginx restart

systemctl restart nginx

 server {
    listen 80;
    location / {
        proxy_pass http://localhost:5000;
        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;
 }
}


502 错误
CentOS: 将NGINX加到SELinux的允许名单
  1. yum install policycoreutils-python  
  2. cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx  
  3. semodule -i mynginx.pp