编译nginx

download code

# nginx
git clone https://github.com/nginx/nginx.git --depth 1 -b branches/stable-1.14

# upstream health check
git clone https://github.com/zhouchangxun/ngx_healthcheck_module -b v1.0 --depth 1

#cookie setting
git clone https://github.com/zhouchangxun/nginx-sticky-module-ng.git --depth 1

# traffic stats
git clone https://github.com/Grim-lock/nginx-module-vts.git -b active_stat --depth 1
git clone https://github.com/Grim-lock/nginx-module-sts.git -b active_stat --depth 1
git clone https://github.com/Grim-lock/nginx-module-stream-sts.git -b active_stat --depth 1

install dependency

yum install -y zlib-devel pcre-devel openssl-devel

build

cd nginx;

./auto/configure 
--prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx 
--modules-path=/usr/lib64/nginx/modules 
--conf-path=/etc/nginx/nginx.conf 
--error-log-path=/var/log/nginx/error.log 
--http-log-path=/var/log/nginx/access.log 
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body 
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy 
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi 
--http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi 
--http-scgi-temp-path=/var/lib/nginx/tmp/scgi 
--pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx 
--with-stream --with-file-aio --with-http_ssl_module --with-http_v2_module 
--add-module=../ngx_healthcheck_module 
--add-module=../nginx-sticky-module-ng 
--add-module=../nginx-module-stream-sts 
--add-module=../nginx-module-sts 
--add-module=../nginx-module-vts 
--with-debug



make && make install 

######################## common conf #####################################

nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    vhost_traffic_status_zone;
    vhost_traffic_status_filter_by_set_key  $server_addr:$server_port;
    stream_server_traffic_status_zone;

    server{
        listen 127.0.0.1:80;
        access_log   off;
        location /http/status {
            check_status json;
        }
        location /stream/status {
            l4check_status json;
        }
        location /stream_stat {
            stream_server_traffic_status_display;
            stream_server_traffic_status_display_format html;
        }
        location /http_stat {
            vhost_traffic_status_display;
            vhost_traffic_status_display_format html;
        }

    }

    include /var/lib/octavia/*/http/*.conf;
}
stream {
    server_traffic_status_zone;
    include /var/lib/octavia/*/stream/*.conf;
}

skill: show nginx compile param

for i in nginx -V 2>&1; do echo $i; done | grep "--"

原文地址:https://www.cnblogs.com/sixloop/p/9132840.html