下载软件
nginx-1.16.1.tar.gznginx-upload-module-2.2.zipopenssl-1.0.2s.tar.gzpcre-8.37.tar.gzzlib-1.2.11.tar.gzngx-fancyindex.tar.gz
解压
tar zxf nginx-1.16.1.tar.gz -C /opttar zxf nginx-upload-module-2.2.zip -C /opttar zxf openssl-1.0.2s.tar.gz -C /opttar zxf pcre-8.37.tar.gz -C /opttar zxf zlib-1.2.11.tar.gz -C /opttar zxf ngx-fancyindex.tar.gz -C /opt
编译安装
cd /opt/nginx-1.16.1./configure --prefix=/opt/nginx \--sbin-path=/opt/nginx/sbin/nginx \--conf-path=/opt/nginx/conf/nginx.conf \--error-log-path=/opt/nginx/log/error.log \--http-log-path=/opt/nginx/log/access.log \--pid-path=/opt/nginx/nginx.pid \--lock-path=/opt/nginx/nginx.lock \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_stub_status_module \--with-http_gzip_static_module \--http-client-body-temp-path=/opt/nginx/client/ \--http-proxy-temp-path=/opt/nginx/proxy/ \--http-fastcgi-temp-path=/opt/nginx/fcgi/ \--http-uwsgi-temp-path=/opt/nginx/uwsgi \--http-scgi-temp-path=/opt/nginx/scgi \--with-stream \--with-stream_ssl_module \--with-stream_realip_module \--with-http_realip_module \--with-http_gunzip_module \--with-http_degradation_module \--with-mail \--with-mail_ssl_module \--with-http_slice_module \--with-threads \--with-http_addition_module \--with-http_auth_request_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_v2_module \--with-http_secure_link_module \--with-pcre-jit \--with-http_sub_module \--with-stream_ssl_preread_module \--with-pcre=/opt/pcre-8.37 \--with-openssl=/opt/openssl-1.0.2s \--with-zlib=/opt/zlib-1.2.11 \--add-module=/opt/nginx-upload-module-2.2--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;
}