优化nginx主配置文件
########################################################################
# This is the main Nginx configuration file.
# More information about the configuration options is available on
# * the English wiki - http://wiki.nginx.org/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################
#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
# http://wiki.nginx.org/NginxHttpMainModule
#
#----------------------------------------------------------------------
user nginx nginx;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 51200;
#error_log /home/logs/nginx/error.log crit;
#error_log /var/log/nginx/error.log notice;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------
events {
use epoll;
multi_accept on;
worker_connections 51200;
}
# Tengine only
# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
# load ngx_http_fastcgi_module.so;
# load ngx_http_rewrite_module.so;
#}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.nginx.org/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_empty_request off; # Tengine only
access_log /var/log/nginx/access.log main buffer=16k;
#server_tokens off; # Nginx only
server_tag zhiliang; # Tengine only
server_info off; # Tengine only
server_names_hash_bucket_size 128;
large_client_header_buffers 4 4k;
client_header_buffer_size 2k;
client_max_body_size 12m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
fastcgi_send_timeout 120s;
fastcgi_read_timeout 120s;
fastcgi_buffer_size 16k;
fastcgi_buffers 32 16k;
fastcgi_busy_buffers_size 16k;
fastcgi_temp_file_write_size 16k;
open_file_cache max=204800 inactive=20s;
open_file_cache_min_uses 1;
open_file_cache_valid 30s;
#open_file_cache_errors on;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_min_length 1k;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
error_page 404 /404.htm;
# fastcgi used by unix socket and not only one pool
upstream phpbackend {
server unix:/dev/shm/php-fpm-www1.sock;
server unix:/dev/shm/php-fpm-www2.sock;
}
include conf.d/*.conf;
}
页:
[1]