下载软件

  1. nginx-1.16.1.tar.gz
  2. nginx-upload-module-2.2.zip
  3. openssl-1.0.2s.tar.gz
  4. pcre-8.37.tar.gz
  5. zlib-1.2.11.tar.gz
  6. ngx-fancyindex.tar.gz

解压

  1. tar zxf nginx-1.16.1.tar.gz -C /opt
  2. tar zxf nginx-upload-module-2.2.zip -C /opt
  3. tar zxf openssl-1.0.2s.tar.gz -C /opt
  4. tar zxf pcre-8.37.tar.gz -C /opt
  5. tar zxf zlib-1.2.11.tar.gz -C /opt
  6. tar zxf ngx-fancyindex.tar.gz -C /opt

编译安装

  1. cd /opt/nginx-1.16.1
  2. ./configure --prefix=/opt/nginx \
  3. --sbin-path=/opt/nginx/sbin/nginx \
  4. --conf-path=/opt/nginx/conf/nginx.conf \
  5. --error-log-path=/opt/nginx/log/error.log \
  6. --http-log-path=/opt/nginx/log/access.log \
  7. --pid-path=/opt/nginx/nginx.pid \
  8. --lock-path=/opt/nginx/nginx.lock \
  9. --user=nginx \
  10. --group=nginx \
  11. --with-http_ssl_module \
  12. --with-http_stub_status_module \
  13. --with-http_gzip_static_module \
  14. --http-client-body-temp-path=/opt/nginx/client/ \
  15. --http-proxy-temp-path=/opt/nginx/proxy/ \
  16. --http-fastcgi-temp-path=/opt/nginx/fcgi/ \
  17. --http-uwsgi-temp-path=/opt/nginx/uwsgi \
  18. --http-scgi-temp-path=/opt/nginx/scgi \
  19. --with-stream \
  20. --with-stream_ssl_module \
  21. --with-stream_realip_module \
  22. --with-http_realip_module \
  23. --with-http_gunzip_module \
  24. --with-http_degradation_module \
  25. --with-mail \
  26. --with-mail_ssl_module \
  27. --with-http_slice_module \
  28. --with-threads \
  29. --with-http_addition_module \
  30. --with-http_auth_request_module \
  31. --with-http_dav_module \
  32. --with-http_flv_module \
  33. --with-http_mp4_module \
  34. --with-http_v2_module \
  35. --with-http_secure_link_module \
  36. --with-pcre-jit \
  37. --with-http_sub_module \
  38. --with-stream_ssl_preread_module \
  39. --with-pcre=/opt/pcre-8.37 \
  40. --with-openssl=/opt/openssl-1.0.2s \
  41. --with-zlib=/opt/zlib-1.2.11 \
  42. --add-module=/opt/nginx-upload-module-2.2
  43. --add-module=/opt/ngx-fancyindex
make
make install

配置主配置文件

worker_processes  auto;
worker_rlimit_nofile 65535;
error_log  /opt/nginx/log/error.log warn;
pid        /opt/nginx/nginx.pid;

events {
    use epoll;
    worker_connections  8192;
}

http {
    include       /opt/nginx/conf/mime.types;
    default_type  application/octet-stream;
    client_max_body_size 5000M;
    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  /opt/nginx/log/access.log  main;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    keepalive_timeout 3600;
    keepalive_requests   100000;
    client_header_timeout 180;
    client_body_timeout 180;
    reset_timedout_connection on;
    client_body_buffer_size 128m;
    proxy_connect_timeout   300s;
    proxy_send_timeout      900;
    proxy_read_timeout      900;
    proxy_buffers 4 128k;
    proxy_busy_buffers_size 256k;
    proxy_temp_file_write_size 256k;
    include /opt/nginx/conf/conf.d/*.conf;
}