linux安裝nginx,設置代理,負載均衡


Linux安裝nginx


首先下載:wget http://nginx.org/download/nginx-1.15.2.tar.gz

 

解壓:tar -xvf nginx-1.15.2.tar.gz

  cd /usr/local/nginx-1.15.2

  ./configure(此步若報錯)

①:checking for C compiler … not found

  yum -y install gcc

  yum -y install gcc-c++

②:error: the HTTP rewrite module requires the PCRE library.

  You can either disable the module by using --without-http_rewrite_module
  option, or install the PCRE library into the system, or build the PCRE library
  statically from the source with nginx by using --with-pcre= option.

  yum -y install openssl openssl-devel

  

然后:

  make

  make install

  /xxx/nginx-1.15.2/objs/nginx    或   /xxx/nginx/nginx (啟動)

  /xxx/nginx/conf/nginx.conf  配置文件

  

  upstream xxx{
    server 127.0.0.1:8080 weight=8;   (weight: 數值越大 權重越高,down: 此服務器不參與輪詢,backup   預留服務器(正式服務器掛了時,啟動預留服務器))
    server 127.0.0.1:8888;
    server 127.0.0.1:9999;
  }

 

  location / {
    root  C:/abc/zxc;
    index index.html index.htm;
    proxy_pass http://xxx;

    (可選項)
    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  nginx.conf 配置文件生效 /xxx/nginx/sbin/nginx -c /xxx/nginx/conf/nginx.conf


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM