萍聚mp3微盘:nginx 详细的中文说明配置文件

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 09:45:46
nginx 详细的中文说明配置文件

nginx 详细的中文说明配置文件

nginx.conf的详细配置代码

  1. #user  nobody;  
  2. worker_processes  1;  
  3.  
  4. #pid文件位置     
  5. pid        logs/nginx.pid;  
  6. #worker_rlimit_nofile 8192;  
  7. #错误日志 可以在下方直接使用 [ debug | info | notice | warn | error | crit ]  参数  
  8. error_log nul;  #关闭日志  
  9. #error_log  logs/error.log;  
  10.  
  11.  
  12. #每个进程最大打开文件数 配置要和系统的单进程打开文件数一致  
  13. worker_rlimit_nofile 65535;  
  14.  
  15. events {  
  16. #   use epoll;          #使用epoll模式  
  17.     worker_connections  65535;  #每个进程的最大连接数  
  18. }  
  19. http {  
  20.     include       mime.types;  
  21.     default_type  application/octet-stream;  
  22. #访问日志配置  
  23. #log_format gzip '$remote_addr - $remote_user |$time_local| '  
  24. #'"$request" $status $bytes_sent '  
  25. #'"$http_referer" "$http_user_agent" "$gzip_ratio"';  
  26. #log_format  gzip  '|来访IP:|$remote_addr|时间:|$time_local|请求:|$request|状态:|$status|字节数:|$body_bytes_sent|浏览器信息:|$http_user_agent|-1-|$http_x_forwarded_for|-2-|$http_referer';  
  27. log_format  alog  '|$time_local|$remote_addr|$gzip_ratio|$request|$http_referer|$status|$body_bytes_sent|$http_user_agent|$http_x_forwarded_for';  
  28.  
  29.  
  30.     #access_log  logs/access.log gzip;  
  31.     #access_log  logs/alog.log alog;  
  32.     access_log nul; #关闭访问日志  
  33.  
  34.     sendfile        on;  
  35.     #tcp_nopush     on;  
  36.  
  37. #nginx处理的最大文件尺寸  
  38.     client_max_body_size 20m;  
  39. #nginx缓冲设置  
  40.     server_names_hash_bucket_size 128;  
  41.     client_header_buffer_size 128k;  
  42.     large_client_header_buffers 8 128k;  
  43.  
  44.     keepalive_timeout  60;  
  45. #fastcgi配置  
  46.     fastcgi_connect_timeout 300;  
  47.     fastcgi_send_timeout 300;  
  48.     fastcgi_read_timeout 300;  
  49.     fastcgi_buffer_size 64k;  
  50.     fastcgi_buffers 4 64k;  
  51.     fastcgi_busy_buffers_size 128k;  
  52.     fastcgi_temp_file_write_size 128k;  
  53.  
  54. #负载均衡  
  55. upstream myfastcgi {  
  56.     server 127.0.0.1:9000 weight=1;  
  57.     server 127.0.0.1:9001 weight=2;  
  58.     server 127.0.0.1:9002 weight=3;  
  59.     server 127.0.0.1:9003 weight=2;  
  60. }  
  61. #Gzip压缩设置  
  62.     gzip            on;  
  63.     gzip_min_length     1k;  
  64.     gzip_buffers        4 16k;  
  65.     gzip_comp_level     8;  
  66.     gzip_http_version   1.0;  
  67.     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;  
  68.     gzip_vary       on;  
  69. #目录索引设置  
  70.     autoindex on;  
  71.     autoindex_localtime on;  
  72. #增加头标  
  73.     add_header Server abans;  
  74. #开启ssi模块  
  75.     ssi on;  
  76.     ssi_silent_errors on;  
  77.     ssi_types text/shtml;  
  78. #是针对每个IP定义一个存储session状态的容器 定义了一个10m的容器 按照32bytes/session 可以处理320000个session  
  79.     limit_zone   one  $binary_remote_addr  10m;  
  80.  
  81. #其它配置文件  
  82.     include abans/*.conf;  
  83.     include e:/au/my/abans/admin/host/vhost/*.conf;  
  84.  
  85.  
  86. }  

ahost.conf 虚拟主机的配置代码

  1. #主机  
  2. server {  
  3.     listen       80;  
  4.     server_name  localhost;  
  5.     root   /au;  
  6.     index  index.html index.htm index.php default.php;  
  7.     #访问日志  
  8.     access_log off;  
  9.     #限制并发连接  
  10.     #limit_conn one   1;  
  11.     #限制连接带宽  
  12.     #limit_rate 10k;  
  13.     #错误页设置  
  14.     error_page   500 502 503 504  /50x.html;  
  15.     location = /50x.html {  
  16.         root    html;  
  17.     }  
  18.     error_page   404  /404.html;  
  19.     location = /404.html {  
  20.         root    html;  
  21.     }  
  22.     location ~ .*\.(php|php5)?$ {  
  23.         fastcgi_pass    myfastcgi;  
  24.         include     afastcgi.conf;  
  25.     }  
  26.     #状态监控  
  27.     location /nginx_status {  
  28.         stub_status on;  
  29.     }  
  30. }  

afastcgi.conf的配置代码

  1. fastcgi_index                     index.php;  
  2. fastcgi_pass_header               Authorization;  
  3. fastcgi_intercept_errors          on;  
  4.  
  5. fastcgi_param  QUERY_STRING       $query_string;  
  6. fastcgi_param  REQUEST_METHOD     $request_method;  
  7. fastcgi_param  CONTENT_TYPE       $content_type;  
  8. fastcgi_param  CONTENT_LENGTH     $content_length;  
  9.  
  10. fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;  
  11. fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;  
  12. fastcgi_param  REQUEST_URI        $request_uri;  
  13. fastcgi_param  DOCUMENT_URI       $document_uri;  
  14. fastcgi_param  DOCUMENT_ROOT      $document_root;  
  15. fastcgi_param  SERVER_PROTOCOL    $server_protocol;  
  16.  
  17. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;  
  18. fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;  
  19.  
  20. fastcgi_param  REMOTE_ADDR        $remote_addr;  
  21. fastcgi_param  REMOTE_PORT        $remote_port;  
  22. fastcgi_param  SERVER_ADDR        $server_addr;  
  23. fastcgi_param  SERVER_PORT        $server_port;  
  24. fastcgi_param  SERVER_NAME        $server_name;  
  25.  
  26. # PHP only, required if PHP was built with --enable-force-cgi-redirect  
  27. fastcgi_param  REDIRECT_STATUS    200;  
  28.