nginx.conf的详细配置代码
- #user nobody;
- worker_processes 1;
- #pid文件位置
- pid logs/nginx.pid;
- #worker_rlimit_nofile 8192;
- #错误日志 可以在下方直接使用 [ debug | info | notice | warn | error | crit ] 参数
- error_log nul; #关闭日志
- #error_log logs/error.log;
- #每个进程最大打开文件数 配置要和系统的单进程打开文件数一致
- worker_rlimit_nofile 65535;
- events {
- # use epoll; #使用epoll模式
- worker_connections 65535; #每个进程的最大连接数
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- #访问日志配置
- #log_format gzip '$remote_addr - $remote_user |$time_local| '
- #'"$request" $status $bytes_sent '
- #'"$http_referer" "$http_user_agent" "$gzip_ratio"';
- #log_format gzip '|来访IP:|$remote_addr|时间:|$time_local|请求:|$request|状态:|$status|字节数:|$body_bytes_sent|浏览器信息:|$http_user_agent|-1-|$http_x_forwarded_for|-2-|$http_referer';
- log_format alog '|$time_local|$remote_addr|$gzip_ratio|$request|$http_referer|$status|$body_bytes_sent|$http_user_agent|$http_x_forwarded_for';
- #access_log logs/access.log gzip;
- #access_log logs/alog.log alog;
- access_log nul; #关闭访问日志
- sendfile on;
- #tcp_nopush on;
- #nginx处理的最大文件尺寸
- client_max_body_size 20m;
- #nginx缓冲设置
- server_names_hash_bucket_size 128;
- client_header_buffer_size 128k;
- large_client_header_buffers 8 128k;
- keepalive_timeout 60;
- #fastcgi配置
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 4 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
- #负载均衡
- upstream myfastcgi {
- server 127.0.0.1:9000 weight=1;
- server 127.0.0.1:9001 weight=2;
- server 127.0.0.1:9002 weight=3;
- server 127.0.0.1:9003 weight=2;
- }
- #Gzip压缩设置
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_comp_level 8;
- gzip_http_version 1.0;
- gzip_types text/plain application/x-javascript text/css application/xml text/vnd.wap.wml application/vnd.ms-excel application/msword application/pdf application/vnd.ms-powerpoint;
- gzip_vary on;
- #目录索引设置
- autoindex on;
- autoindex_localtime on;
- #增加头标
- add_header Server abans;
- #开启ssi模块
- ssi on;
- ssi_silent_errors on;
- ssi_types text/shtml;
- #是针对每个IP定义一个存储session状态的容器 定义了一个10m的容器 按照32bytes/session 可以处理320000个session
- limit_zone one $binary_remote_addr 10m;
- #其它配置文件
- include abans/*.conf;
- include e:/au/my/abans/admin/host/vhost/*.conf;
- }
ahost.conf 虚拟主机的配置代码
- #主机
- server {
- listen 80;
- server_name localhost;
- root /au;
- index index.html index.htm index.php default.php;
- #访问日志
- access_log off;
- #限制并发连接
- #limit_conn one 1;
- #限制连接带宽
- #limit_rate 10k;
- #错误页设置
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- error_page 404 /404.html;
- location = /404.html {
- root html;
- }
- location ~ .*\.(php|php5)?$ {
- fastcgi_pass myfastcgi;
- include afastcgi.conf;
- }
- #状态监控
- location /nginx_status {
- stub_status on;
- }
- }
afastcgi.conf的配置代码
- fastcgi_index index.php;
- fastcgi_pass_header Authorization;
- fastcgi_intercept_errors on;
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name;
- fastcgi_param REQUEST_URI $request_uri;
- fastcgi_param DOCUMENT_URI $document_uri;
- fastcgi_param DOCUMENT_ROOT $document_root;
- fastcgi_param SERVER_PROTOCOL $server_protocol;
- fastcgi_param GATEWAY_INTERFACE CGI/1.1;
- fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
- fastcgi_param REMOTE_ADDR $remote_addr;
- fastcgi_param REMOTE_PORT $remote_port;
- fastcgi_param SERVER_ADDR $server_addr;
- fastcgi_param SERVER_PORT $server_port;
- fastcgi_param SERVER_NAME $server_name;
- # PHP only, required if PHP was built with --enable-force-cgi-redirect
- fastcgi_param REDIRECT_STATUS 200;