nginx 随记
依赖项
zlib,zlib-devel,openssl,openssl-devel,prce,prce-devel
编译参数
--prefix=/usr/local/nginx --pid-path=/run/nginx.pid --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre
主配置
1 user nginx; 2 worker_processes auto; 3 pid run/nginx.pid; 4 worker_rlimit_nofile 65536;#指定一个worker能打开的最大文件描述符 5 error_log logs/nginx_error.log;#可以在后面加上level 调试时可设为debug 但是在编译的时候要使用--with-debug 6 #load_module /usr/local/nginx/modules/ngx_stream_module.so; 7 #worker_rlimit_sigpending 指定每个用户能够发往worker进程的信号的数量
#worker_cpu_affinity 0001 0010 0100 1000 指定cpu核运行
#daemon 是否以守护进程运行 调试使用
#master_process on|off 是否以master/worker的模型运行
8 events { 9 use epoll; 10 worker_connections 65536;# 11 multi_accept on; 12 } 13 #include stream.d/*.conf; 14 http { 15 include mime.types; 16 default_type application/octet-stream; 17 map $http_upgrade $connection_upgrade { 18 default upgrade; 19 '' close; 20 } 21 22 23 log_format main '$remote_addr $remote_port $ssl_protocol [$time_iso8601] "$request_method $scheme://$host$request_uri $server_protocol" ' 24 '$status $body_bytes_sent "$http_referer" ' 25 '{$http_user_agent} "$http_x_forwarded_for" "$request_time" "$upstream_addr" "$upstream_response_time"' ; 26 27 access_log /home/nginx_log/access.log main; 28 server_names_hash_bucket_size 51200; 29 client_header_buffer_size 64k; 30 large_client_header_buffers 4 64k; 31 client_max_body_size 1024m; 32 sendfile on; 33 tcp_nopush on; 34 server_tokens off; 35 send_timeout 120; 36 keepalive_timeout 120; 37 gzip on; 38 gzip_buffers 128 32k; 39 gzip_types text/plain application/javascript text/css application/xml; 40 gzip_static on; 41 gzip_min_length 1k; 42 gzip_http_version 1.1; 43 gzip_proxied any; 44 gzip_disable "MSIE [1-6]\."; 45 gzip_comp_level 6; 46 proxy_set_header Host $host; 47 proxy_set_header X-Forwarded-For $http_x_forwarded_for; 48 proxy_http_version 1.1; 49 proxy_buffer_size 512k; 50 proxy_buffers 128 32k; 51 proxy_busy_buffers_size 512k; 52 proxy_connect_timeout 60s; 53 proxy_cookie_domain off; 54 proxy_ignore_client_abort off; 55 proxy_intercept_errors on; 56 proxy_read_timeout 60s; 57 proxy_ssl_session_reuse on; 58 proxy_set_header x-forwarded-proto $scheme; 59 60 #server { 61 # listen 80; 62 # server_name _ ; 63 # location / { 64 # return 403; 65 # } 66 #} 67 68 include webconf/*.conf; 69 }
nginx 支持 thinkphp5
1 location / { 2 if ( -f $request_filename){ 3 break; 4 } 5 if ( !-e $request_filename){ 6 rewrite ^(.*)$ /index.php/$1 last; 7 break; 8 } 9 } 10 11 12 13 14 location ~ \.php(.*)$ { 15 fastcgi_pass 127.0.0.1:9000; 16 fastcgi_index index.php; 17 #下面两句是给fastcgi权限,可以支持 ?s=/module/controller/action的url访问模式 18 fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; 19 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 20 #下面两句才能真正支持 index.php/index/index/index的pathinfo模式 21 fastcgi_param PATH_INFO $fastcgi_path_info; 22 fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 23 include fastcgi_params; 24 }