zoukankan      html  css  js  c++  java
  • nginx搭建分布式简单配置

    一、安装nginx

               安装nginx

        概要

    安装编译工具及库文件
    yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
    下载解压缩 nginx  pcre
    tar zxvf pcre-8.43.tar.gz 
    查看pcre版本
    rpm -qa pcre
    查看pcre安装目录
    rpm -ql pcre
    配置
     ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/**/src/ --with-pcre=/usr/local/soft/pcre-8.43
    编译
    make && make install
    nginx 版本查看
    /usr/local/webserver/nginx/sbin/nginx -v
    启动
    /usr/local/webserver/nginx/sbin/nginx
    重启
    /usr/local/webserver/nginx/sbin/nginx -s reload
    关闭
    /usr/local/webserver/nginx/sbin/nginx -s stop

    二、编写配置文件 nginx.conf

    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
    
        keepalive_timeout  65;
    
     upstream test {  
          #根据ip计算将请求分配各那个后端tomcat,许多人误认为可以解决session问题,其实并不能。  
          #同一机器在多网情况下,路由切换,ip可能不同  
          #ip_hash;   
          server ****:8180;
          server ****:8180;
        }
    
    
        server {
                listen       8180;
                server_name  test;
    
                #对aspx后缀的进行负载均衡请求
            location / {
              proxy_connect_timeout 3;  
              proxy_send_timeout 30;  
              proxy_read_timeout 30;  
              proxy_pass http://test/;  #对应upstream
                      
            }
    
            add_header X-Via $server_addr;
            add_header X_cache_hit $upstream_cache_status;
        }
    }

    三、启动ngnix(指定配置文件)

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

     四、关闭重启

    /usr/local/nginx/sbin/nginx -s reload
    /usr/local/nginx/sbin/nginx -s stop
  • 相关阅读:
    【USACO10JAN】Cheese Towers S 奶酪塔 (背包dp)
    【SDOI2015】排序(dfs+结论)
    【NOI2014】购票(树形dp+树剖+斜率优化)
    【BZOJ3329】Xorequ(数位dp+矩阵快速幂)
    [NOI 2012] 骑行川藏
    BZOJ
    [学习笔记] 上下界网络流
    [八省联考 2018] 劈配
    P4313 文理分科
    [SDOI 2015] 序列统计
  • 原文地址:https://www.cnblogs.com/superslow/p/9952875.html
Copyright © 2011-2022 走看看