nginx编译安装使用

阅读更多

mkdir nginx

cd nginx

yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel lua-devel

yum -y install libxml2 libxslt libxml2-dev libxslt-devel gd-devel patch

yum -y install perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data

 

 

wget http://nginx.org/download/nginx-1.14.2.tar.gz

wget https://github.com/libunwind/libunwind/releases/download/v1.3.1/libunwind-1.3.1.tar.gz

wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.7/gperftools-2.7.tar.gz

wget https://github.com/openresty/echo-nginx-module/archive/master.zip

wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/master.zip

wget https://github.com/alibaba/nginx-http-concat/archive/1.2.2.tar.gz

wget https://github.com/vozlt/nginx-module-vts/archive/v0.1.18.tar.gz

wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1.tar.gz

 

tar xvzf nginx-1.14.2.tar.gz

tar xvzf libunwind-1.3.1.tar.gz

tar xvzf gperftools-2.7.tar.gz

unzip master.zip

unzip master.zip.1

tar xvzf 1.2.2.tar.gz

tar xvzf v0.1.18.tar.gz

tar xvzf v0.3.1.tar.gz

 

mv echo-nginx-module-master nginx-1.14.2/

mv nginx-http-concat-1.2.2 nginx-1.14.2/

mv nginx-module-vts-0.1.18 nginx-1.14.2/

mv nginx_upstream_check_module-master nginx-1.14.2/

mv ngx_devel_kit-0.3.1 nginx-1.14.2/

 

cd libunwind-1.3.1

./autogen.sh

./configure

make && make install

cd ..

 

cd gperftools-2.7

./configure

make && make install

cd ..

cd nginx-1.14.2

patch -p1 < nginx_upstream_check_module-master/check_1.14.0+.patch

 

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf

ldconfig

 

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --http-client-body-temp-path=/usr/local/nginx/temp/client_body --http-proxy-temp-path=/usr/local/nginx/temp/proxy --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/temp/uwsgi --http-scgi-temp-path=/usr/local/nginx/temp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --add-module=echo-nginx-module-master --add-module=nginx-module-vts-0.1.18 --add-module=nginx-http-concat-1.2.2 --add-module=nginx_upstream_check_module-master --add-module=ngx_devel_kit-0.3.1 --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --with-ld-opt='-Wl,-rpath,/usr/local/lib'

 

make && make install

useradd -s /sbin/nologin -M nginx

mkdir -p /usr/local/nginx/sbin/

mkdir -p /usr/local/nginx/temp/client_body

mkdir -p /usr/local/nginx/temp/proxy

mkdir -p /usr/local/nginx/temp/fastcgi

mkdir -p /usr/local/nginx/temp/uwsgi

mkdir -p /usr/local/nginx/temp/scgi

# 启动

/usr/local/nginx/sbin/nginx

 

配置nginx.conf进行验证

http { 
   vhost_traffic_status_zone;

   upstream www_server_pools {
        server 192.168.0.131:80 weight=1;
        server 192.168.0.132:80 weight=1;
        check interval=3000 rise=2 fall=3 timeout=1000 type=http;
        check_http_send "HEAD /check_health?app=check HTTP/1.0\r\n\r\n";
        check_http_expect_alive http_2xx http_3xx;
   }

    server {
        listen       80;
        server_name  linwenguo.com;

        location / {
                proxy_pass http://www_server_pools;
                include proxy.conf;
        }
        
        location /status {
                check_status;
                access_log off;
        }

        location ^~ /traffic_status {
                vhost_traffic_status_display;
                vhost_traffic_status_display_format html;
        }
    }
}

 

你可能感兴趣的:(nginx)