nginx基础配置

nginx.conf

  1. #user nobody;
  2. worker_processes 1;
  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. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. #access_log logs/access.log main;
  14. sendfile on;
  15. #tcp_nopush on;
  16. #keepalive_timeout 0;
  17. keepalive_timeout 65;
  18. client_max_body_size 20m;
  19. #gzip on;
  20. server {
  21. listen 80;
  22. server_name localhost;
  23. location / {
  24. root D:\xxx\public;
  25. index index.html index.htm index.php;
  26. try_files $uri $uri/ /index.php?$query_string;
  27. }
  28. location ~ ^/(images|javascript|js|css|flash|media|static)/ {
  29. root D:\xxx\public;
  30. expires 30d;
  31. }
  32. error_page 500 502 503 504 /50x.html;
  33. location = /50x.html {
  34. root html;
  35. }
  36. location ~ \.php$ {
  37. root D:\xxx\public;
  38. fastcgi_pass localhost:9000;
  39. fastcgi_index index.php;
  40. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  41. include fastcgi_params;
  42. }
  43. }
  44. include web-other.conf;
  45. }