生产环境下的nginx.conf配置文件(多虚拟主机)

 

   我的生产环境下的nginx.conf配置文件,做了虚拟主机设置的,大家可以根据需求更改,下载即可在自己的机器上使用了,本配置文件摘录自《构建高可用Linux服务器》(机械工业出版社),转载麻烦注明出处,谢谢,配置文件如下:

  1. user  www www; 
  2. worker_processes 8; 
  3. error_log  /data/logs/nginx_error.log  crit; 
  4. pid        /usr/local/webserver/nginx/nginx.pid; 
  5.  
  6. #Specifies the value for maximum file descriptors that can be opened by this process.  
  7. worker_rlimit_nofile 65535; 
  8. events  
  9.   use epoll; 
  10.   worker_connections 65535; 
  11.  
  12. http  
  13.   include       mime.types; 
  14.   default_type  application/octet-stream; 
  15.   #charset  gb2312; 
  16.   server_names_hash_bucket_size 128; 
  17.   client_header_buffer_size 32k; 
  18.   large_client_header_buffers 4 32k; 
  19.   client_max_body_size 8m; 
  20.        
  21.   sendfile on; 
  22.   tcp_nopush     on; 
  23.   keepalive_timeout 60; 
  24.   tcp_nodelay on; 
  25.  
  26.   fastcgi_connect_timeout 300; 
  27.   fastcgi_send_timeout 300; 
  28.   fastcgi_read_timeout 300; 
  29.   fastcgi_buffer_size 64k; 
  30.   fastcgi_buffers 4 64k; 
  31.   fastcgi_busy_buffers_size 128k; 
  32.   fastcgi_temp_file_write_size 128k; 
  33.  
  34.   gzip on; 
  35.   gzip_min_length  1k; 
  36.   gzip_buffers     4 16k; 
  37.   gzip_http_version 1.0; 
  38.   gzip_comp_level 2; 
  39.   gzip_types       text/plain application/x-javascript text/css application/xml; 
  40.   gzip_vary on; 
  41.  
  42.   #limit_zone  crawler  $binary_remote_addr  10m; 
  43.   server  
  44.   { 
  45.     listen 80 default; 
  46.     server_name _; 
  47.     index index.html index.htm index.php; 
  48.     root /data/htdocs/www; 
  49.     #server_name_in_redirect off; 
  50.      
  51.     location ~ .*\.(php|php5)?$ 
  52.     { 
  53.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  54.       fastcgi_pass  127.0.0.1:9000; 
  55.       fastcgi_index index.php; 
  56.       include fcgi.conf; 
  57.     } 
  58.  
  59.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  60.     { 
  61.       expires      30d; 
  62.     } 
  63.  
  64.     location ~ .*\.(js|css)?$ 
  65.     { 
  66.       expires      1h; 
  67.     } 
  68.  
  69.     } 
  70.  
  71.   server 
  72.   { 
  73.     listen       80; 
  74.     server_name  www.adongstudio.com; 
  75.     index index.html index.htm index.php; 
  76.     root  /data/htdocs/www/adongweb; 
  77.  
  78.     #limit_conn   crawler  20;     
  79.     location ~ .*\.(php|php5)?$ 
  80.     {       
  81.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  82.       fastcgi_pass  127.0.0.1:9000; 
  83.       fastcgi_index index.php; 
  84.       include fcgi.conf; 
  85.     } 
  86.      
  87.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  88.     { 
  89.       expires      30d; 
  90.     } 
  91.  
  92.     location ~ .*\.(js|css)?$ 
  93.     { 
  94.       expires      1h; 
  95.     }     
  96.  
  97.     log_format  access  '$remote_addr - $remote_user [$time_local] "$request" ' 
  98.               '$status $body_bytes_sent "$http_referer" ' 
  99.               '"$http_user_agent" $http_x_forwarded_for'; 
  100.     access_log  /data/logs/access.log  access; 
  101.       } 
  102.  
  103.   server 
  104.   { 
  105.     listen       80; 
  106.     server_name  www.longfeistudio.com; 
  107.     index index.html index.htm index.php; 
  108.     root  /data/htdocs/www/ImageVue; 
  109.  
  110.     #limit_conn   crawler  20; 
  111.    
  112.     location ~ .*\.(php|php5)?$ 
  113.     { 
  114.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  115.       fastcgi_pass  127.0.0.1:9000; 
  116.       fastcgi_index index.php; 
  117.       include fcgi.conf; 
  118.     } 
  119.    
  120.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  121.     { 
  122.       expires      30d; 
  123.     } 
  124.  
  125.     location ~ .*\.(js|css)?$ 
  126.     { 
  127.       expires      1h; 
  128.     } 
  129.  
  130.     access_log  off; 
  131.       } 
  132.  
  133.   server 
  134.   { 
  135.     listen       80; 
  136.     server_name  www.hongyanbike.com; 
  137.     index index.html index.htm index.php; 
  138.     root  /data/htdocs/www/xhui/hybike; 
  139.  
  140.     location ~ .*\.(php|php5)?$ 
  141.     {       
  142.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  143.       fastcgi_pass  127.0.0.1:9000; 
  144.       fastcgi_index index.php; 
  145.       include fcgi.conf; 
  146.     } 
  147.      
  148.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  149.     { 
  150.       expires      30d; 
  151.     } 
  152.  
  153.     location ~ .*\.(js|css)?$ 
  154.     { 
  155.       expires      1h; 
  156.     } 
  157.  
  158.     access_log  off; 
  159.   } 
  160.  
  161. server 
  162.   { 
  163.     listen       80; 
  164.     server_name  www.very365.com mm.very365.com very365.com;     
  165.     index index.html index.htm index.php; 
  166.     root  /data/htdocs/www/very365;    
  167.   location / 
  168.   {      
  169.   rewrite ^/(.*)/product/([0-9]+)/$ /seoproduct\.php\?spell=$1&productid=$2; 
  170.   rewrite ^/brand/(.*)/page/([0-9]+)/$ /seobrand\.php\?spell=$1&page=$2; 
  171.   rewrite ^/brand/(.*)/$ /seobrand\.php\?spell=$1; 
  172.  
  173.     } 
  174.     location ~ .*\.(php|php5)?$ 
  175.     { 
  176.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  177.       fastcgi_pass  127.0.0.1:9000; 
  178.       fastcgi_index index.php; 
  179.       include fcgi.conf; 
  180.       fastcgi_param SCRIPT_FILENAME /data/htdocs/www/very365$fastcgi_script_name; 
  181.       fastcgi_param  SCRIPT_NAME  /data/htdocs/www/very365$fastcgi_script_name; 
  182.     } 
  183.  
  184.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  185.     { 
  186.       expires      30d; 
  187.     } 
  188.  
  189.     location ~ .*\.(js|css)?$ 
  190.     { 
  191.       expires      1h; 
  192.     } 
  193.  
  194.     access_log  off; 
  195.  
  196.   } 
  197. server 
  198.   { 
  199.     listen       80; 
  200.     server_name  www.wqueen.cn wqueen.cn; 
  201.  
  202.  
  203.     index index.html index.htm index.php; 
  204.     root  /data/htdocs/www/wqueen/bbs; 
  205.  
  206.     location ~ .*\.(php|php5)?$ 
  207.     { 
  208.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  209.       fastcgi_pass  127.0.0.1:9000; 
  210.       fastcgi_index index.php; 
  211.       include fcgi.conf; 
  212.     } 
  213.  
  214.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  215.     { 
  216.       expires      30d; 
  217.     } 
  218.  
  219.     location ~ .*\.(js|css)?$ 
  220.     { 
  221.       expires      1h; 
  222.     } 
  223.  
  224.     access_log  off; 
  225.     } 
  226. server 
  227.   { 
  228.     listen       80; 
  229.     server_name  baobei.wqueen.cn; 
  230.     index index.html index.htm index.php; 
  231.     root  /data/htdocs/www/baobei; 
  232.  
  233.     location ~ .*\.(php|php5)?$ 
  234.     { 
  235.       #fastcgi_pass  unix:/tmp/php-cgi.sock; 
  236.       fastcgi_pass  127.0.0.1:9000; 
  237.       fastcgi_index index.php; 
  238.       include fcgi.conf; 
  239.     } 
  240.  
  241.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  242.     { 
  243.       expires      30d; 
  244.     } 
  245.  
  246.     location ~ .*\.(js|css)?$ 
  247.     { 
  248.       expires      1h; 
  249.     } 
  250.  
  251.     access_log  off; 
  252.     }