user www www; worker_processes 8; error_log /data1/logs/nginx_error.log crit; pid /usr/local/webserver/nginx/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; #charset utf-8; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; sendfile on; #tcp_nopush on; keepalive_timeout 30; tcp_nodelay on; #注:fastcgi_temp_path和fastcgi_cache_path指定的路径必须在同一分区 fastcgi_temp_path /data0/fastcgi_temp_path; #设置Web缓存区名称为cache_one,内存缓存空间大小为500MB,自动清除超过1天没有被访问的缓存数据,硬盘缓存空间大小为30GB。 fastcgi_cache_path /data0/fastcgi_cache_path levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g; upstream my_server_pool { server 192.168.1.2:80 weight=1 max_fails=2 fail_timeout=30s; server 192.168.1.3:80 weight=1 max_fails=2 fail_timeout=30s; server 192.168.1.4:80 weight=1 max_fails=2 fail_timeout=30s; } server { listen 80; server_name my.domain.com; root /data0/htdocs; location ~ .*\.(php|php5)$ { #使用Web缓存区cache_one fastcgi_cache cache_one; #对不同HTTP状态码缓存设置不同的缓存时间 fastcgi_cache_valid 200 10m; fastcgi_cache_valid 301 302 1h; fastcgi_cache_valid any 1m; #设置Web缓存的Key值,Nginx根据Key值md5哈希存储缓存,这里根据“FastCGI服务器的IP、端口、请求的URI”组合成Key。 fastcgi_cache_key 127.0.0.1:9000$request_uri; #FastCGI服务器 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } access_log off; } }