Linux安装nginx


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

linux安装nginx,设置代理,负载均衡

 

解压: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

  /usr/local/nginx-1.15.2/objs/nginx    或   /usr/local/nginx/nginx (启动)

  /usr/local/nginx/conf/nginx.conf  配置文件

  

  upstream wzz {
    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 html;
    index index.html index.htm;
    proxy_pass http://wzz;

    (可选项)
    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  

相关文章:

  • 2021-09-01
  • 2021-06-14
  • 2022-02-10
  • 2022-01-08
  • 2021-11-22
  • 2022-12-23
  • 2021-07-26
  • 2021-11-27
猜你喜欢
  • 2021-12-03
  • 2021-12-11
  • 2022-12-23
  • 2021-11-22
  • 2022-01-16
相关资源
相似解决方案