zoukankan      html  css  js  c++  java
  • nginx动静分离

    192.168.126.8 主服务器
    192.168.126.7 静态节点
    192.168.126.6 动态节点
    [wangluoyuan]
    name=wanglouyuan1
    enabled=1
    gpgcheck=0
    baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
    cost=1
    [centos]
    name=centos163
    enabled=1
    gpgcheck=0
    baseurl=http://mirrors.163.com/centos/7/os/x86_64/
    需要用到的网络源
    关闭防火墙
    Setenforce 0
    Systemctl stop firewalld
    第一步:下载nginx

    ╭─root@zxw ~
    ╰─➤ yum install nginx -y
    第二步:主服务配置动静分离规则
    ╭─root@zxw ~
    ╰─➤ vim /etc/nginx/nginx.conf

    location ~ html$ {
    proxy_pass http://192.168.126.7;
    }
    location ~ php$ {
    proxy_pass http://192.168.126.6;
    }
    第三步:检查并重启
    ╭─root@zxw ~
    ╰─➤ nginx -t
    nginx: /etc/nginx/nginx.conf syntax is ok

    ╭─root@zxw ~
    ╰─➤ systemctl restart nginx
    配置静态服务器192.168.126.7
    一:[root@zxw ~]# yum install nginx -y
    二:[root@zxw ~]# cd /usr/share/nginx/html/
    [root@zxw html]# ls
    404.html 50x.html index.html nginx-logo.png poweredby.png
    三:[root@zxw html]# vim index.html
    四:[root@zxw html]# systemctl restart nginx
    配置动态服务器192.168.126.6
    一:[root@006 ~]# yum install php httpd -y
    二:[root@006 ~]# vim /var/www/html/index.php
    <?php
    phpinfo();
    ?>
    ~
    三:[root@006 ~]# systemctl restart httpd

  • 相关阅读:
    linux系统日志使用
    C# progressbar 用法
    python 新时代
    linux 常用命令 集锦
    c# DirectoryInfo类 详解
    哈佛(转)
    寒门难再出贵子
    排序算法
    JavaScript弹出框
    js中innerHTML与innerText的用法与区别
  • 原文地址:https://www.cnblogs.com/itzhao/p/11249948.html
Copyright © 2011-2022 走看看