美文网首页程序员
Nginx安装及代理

Nginx安装及代理

作者: 小世界的野孩子 | 来源:发表于2019-04-08 15:59 被阅读0次

    1、第一步 - 添加Nginx存储库

    要添加CentOS 7 EPEL存储库,请打开终端并使用以下命令:

    sudo yum install epel-release

    2、第二步 - 安装Nginx

    现在您的服务器上已安装Nginx存储库,请使用以下yum命令安装Nginx :

    sudo yum install nginx

    在对提示回答“是”后,Nginx将在您的虚拟专用服务器(VPS)上完成安装。

    3、第三步 - 启动Nginx

    Nginx并不是自己开始的。要运行Nginx,请键入:

    sudo systemctl start nginx

    sudo systemctl enable nginx

    4、如果您运行的是防火墙,请运行以下命令以允许HTTP和HTTPS流量:

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

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

    sudo firewall-cmd --reload

    直接访问你的ip,出现nginx页面则安装成功

    5、查看nginx运行状态

    sudo systemctl status nginx.service

    6、找到配置文件

    sudo vi /etc/nginx/nginx.conf

    7、修改server

    server {

        listen 80;

        location / {

      proxy_pass http://localhost:8082;

      proxy_http_version 1.1;

      proxy_set_header Upgrade $http_upgrade;

      proxy_set_header Connection keep-alive;

      proxy_set_header Host $http_host;

      proxy_cache_bypass $http_upgrade;

      }

    }

    将80转发至8082端口:例如:发布访问地址192.168.00.000:8082,转发之后可直接访问192.168.00.000

    8、重启nginx

    sudo nginx -t

    sudo nginx -s reload

    9、设置开机启动

    重启nginx服务

    systemctl enable nginx.service

    下载

    wget https://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm

    解压

    rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm

    设置

    setsebool -P httpd_can_network_connect 1

    yum install libgdiplus-devel

    10、重启虚拟机

    安装基础工具

    yum install net-tools  

    安装VIM

    yum -y install vim

    安装 wget

    yum -y install wget

    相关文章

      网友评论

        本文标题:Nginx安装及代理

        本文链接:https://www.haomeiwen.com/subject/ficpiqtx.html