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
  • 相关阅读:
    高效 JavaScript
    什么是QName【转】
    gson的简单使用方法
    SWT的FormLayout
    SWT/JFace常用组件容器类
    更改swing应用程序标题栏默认图标
    面试也是自己对自己的面试
    关于Android图片cache处理方法
    【Java】_2_Java程序入门第二课
    【算法和数据结构】_9_线性结构_队列_续_1
  • 原文地址:https://www.cnblogs.com/superslow/p/9952875.html
Copyright © 2011-2022 走看看