四、修改好之后的/usr/local/nginx/conf/nginx.conf配置文件如下(建议直接使用这个修改好的文件)

 

  1. user  www www; 
  2. worker_processes  2; 
  3. #error_log  logs/error.log; 
  4. #error_log  logs/error.log  notice; 
  5. #error_log  logs/error.log  info; 
  6. #pid        logs/nginx.pid; 
  7.   
  8. events { 
  9.     use epoll; 
  10.     worker_connections  65535; 
  11.   
  12. http { 
  13.     include       mime.types; 
  14.     default_type  application/octet-stream; 
  15.   
  16.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ' 
  17.     #                  '$status $body_bytes_sent "$http_referer" ' 
  18.     #                  '"$http_user_agent" "$http_x_forwarded_for"'
  19.   
  20.     #access_log  logs/access.log  main; 
  21.     server_names_hash_bucket_size 128; 
  22.     client_header_buffer_size 32k; 
  23.     large_client_header_buffers 4 32k; 
  24.     client_max_body_size 300m; 
  25.     sendfile        on
  26.     tcp_nopush     on
  27.     fastcgi_connect_timeout 300; 
  28.     fastcgi_send_timeout 300; 
  29.     fastcgi_read_timeout 300; 
  30.     fastcgi_buffer_size 64k; 
  31.     fastcgi_buffers 4 64k; 
  32.     fastcgi_busy_buffers_size 128k; 
  33.     fastcgi_temp_file_write_size 128k; 
  34.     #keepalive_timeout  0; 
  35.     keepalive_timeout  60; 
  36.     tcp_nodelay on
  37.     server_tokens off
  38.     gzip  on
  39.     gzip_min_length  1k; 
  40.     gzip_buffers     4 16k; 
  41.     gzip_http_version 1.1; 
  42.     gzip_comp_level 2; 
  43.     gzip_types       text/plain application/x-javascript text/css application/xml; 
  44.     gzip_vary on
  45.    server { 
  46.      listen       80 default
  47.      server_name  _; 
  48.      location / { 
  49.      root   html; 
  50.      return 404; 
  51.                     } 
  52.      location ~ /.ht { 
  53.      deny  all
  54.                       } 
  55.        } 
  56.    server 
  57.         { 
  58.      listen       80; 
  59.      #server_name localhost; 
  60.      index index.php default.php index.html index.htm default.html default.htm ; 
  61.      root /data/osyunwei; 
  62. location ~ .*\.(php|php5)?$ 
  63.                         { 
  64.                                 fastcgi_pass  unix:/tmp/php-cgi.sock; 
  65.                                 fastcgi_index index.php; 
  66.                                 include fcgi.conf; 
  67.                         } 
  68.                 location /status { 
  69.                         stub_status on
  70.                         access_log   off
  71.                 } 
  72.   
  73.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 
  74.                         { 
  75.                                 expires      30d; 
  76.                         } 
  77.                 location ~ .*\.(js|css)?$ 
  78.                         { 
  79.                                 expires      12h; 
  80.                         } 
  81.   
  82.                 access_log off
  83.         } 
  84.   
  85. include  vhost/*.conf; 

五、创建fcgi.conf配置文件

vi /usr/local/nginx/conf/fcgi.conf  #添加以下内容

 

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