nginx安装

1、yum install gcc gcc-c++

2、tar -jxvf jemalloc-5.2.1.tar.bz2

3、cd jemalloc-5.2.1

4、./configure --prefix=/usr/local/jemalloc

make

make install

5、yum install openssl openssl-devel -y

6、./configure --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --prefix=/usr/local/nginx --with-jemalloc=/usr/local/jemalloc-5.2.1 --with-stream --add-module=./modules/ngx_http_upstream_check_module/  --without-http_rewrite_module

7、

make

make install

8、

vim /usr/local/nginx/conf/nginx.conf

添加下方配置

  upstream mspp {

        server 192.168.10.253:8080;

        server 192.168.10.252:8080;

        server 192.168.10.133:8080;

        check interval=3000 rise=2 fall=5 timeout=1000 type=http;

        check_http_send "HEAD / HTTP/1.0 ";

        check_http_expect_alive http_2xx http_3xx;

    }

    server {

        listen       80;

        server_name  localhost

         location / {

            proxy_pass http://mspp;

        }

          location /status {

            check_status;

            access_log   off;

            #allow SOME.IP.ADD.RESS;

            #deny all;

        }

error_page   500 503 504  /50x.html;

location = /50x.html {

            root   html;

        }

        error_page 502 /502;

        location = /502 {

            default_type application/json;

                add_header Content-Type 'text/html; charset=utf-8';

                return 200 '{"code":"6666,"msg":"服务正在维护中,请稍后再试!"}';

        }

 }

启动服务

sbin/nginx -c conf/nginx.conf

原文地址:https://www.cnblogs.com/bzdmz/p/11526028.html