thinkphp的nginx配置文件

  1. server {
  2. listen 80;
  3. server_name thinkphp.lo;
  4. root /var/www;
  5. index index.html index.htm index.php;
  6. error_page 404/404.html;
  7. location =/404.html{
  8. return404'Sorry, File not Found!';
  9. }
  10. error_page 500502503504/50x.html;
  11. location =/50x.html {
  12. root /usr/share/nginx/html;# windows用户替换这个目录
  13. }
  14. location /{
  15. set $static 0;
  16. set $exsit 0;
  17. if($uri ~ .(css|js|jpg|png|gif|ico|woff|eot|svg|css.map)$){
  18. set $static 1;
  19. }
  20. if(-e $request_filename){
  21. set $exsit 1;
  22. }
  23. set $static_exsit $static$exsit;
  24. if($static_exsit =00){
  25. rewrite ^/(.*)$ /index.php?s=/$1;
  26. }
  27. }
  28. location ~ .php/{
  29. if($request_uri ~^(.+.php)(/.+)$){}
  30. fastcgi_pass 127.0.0.1:9000;
  31. include fastcgi_params;
  32. fastcgi_param SCRIPT_NAME $1;
  33. fastcgi_param PATH_INFO $2;
  34. fastcgi_param SCRIPT_FILENAME $document_root$1;
  35. }
  36. location ~ .php {
  37. fastcgi_pass 127.0.0.1:9000;
  38. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  39. include fastcgi_params;
  40. }
  41. location ~/Uploads/.*.php$ {
  42. deny all;
  43. }
  44. location ~/.ht {
  45. deny all;
  46. }
  47. }