thinkphp nginx 配置文件

  1. 根目录有多个地方记得都要修改
  2. server {
  3.     listen       80;
  4.     server_name  www.xxx.com  xxx.com;
  5.        if ($host != 'www.xxx.com' ) {
  6.           rewrite ^/(.*)$ http://www.xxx.com/$1 permanent;
  7.         }
  8.     #charset koi8-r;
  9.     #access_log  /var/log/nginx/log/host.access.log  main;
  10.     root  /home/www/xxx.com;
  11.     location / {
  12.         index index.php index.html index.htm;
  13.          try_files $uri $uri/ /index.html;
  14.                 # Uncomment to enable naxsi on this location
  15.                 # include /etc/nginx/naxsi.rules
  16.                 if (!-e $request_filename)
  17.                 {
  18.                        # rewrite ^/PHPParser/(.*)$ /PHPParser/index.php?s=$1 last;
  19.                        rewrite ^/index.php(.*)$ /index.php?s=$1 last;
  20.                        rewrite ^(.*)/index.php?s=$1 last;
  21.                         rewrite ^/(.*)$ /index.php/$1;
  22.                         break;
  23.                 }
  24.     }
  25.     #error_page  404              /404.html;
  26.     # redirect server error pages to the static page /50x.html
  27.     #
  28.     error_page   500 502 503 504  /50x.html;
  29.     location = /50x.html {
  30.     #项目地址
  31.         root   /home/www/xxx.com;
  32.        # root   /usr/share/nginx/html;
  33.     }
  34.     # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  35.     #
  36.     #location ~ \.php$ {
  37.     #    proxy_pass   http://127.0.0.1;
  38.     #}
  39.     location ~ \.php$ {
  40.     #项目地址
  41.     root   /home/www/xxx.com;
  42.     #root   /usr/share/nginx/html;
  43.     fastcgi_pass 127.0.0.1:9000;
  44.     fastcgi_split_path_info ^(.+\.php)(.*)$;
  45.     fastcgi_param PATH_INFO $fastcgi_path_info;
  46.     fastcgi_index index.php;
  47.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  48.     include /etc/nginx/fastcgi_params;
  49.     try_files $uri =404;
  50.     }
  51.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  52.     #
  53.     #location ~ \.php$ {
  54.     #    root           html;
  55.     #    fastcgi_pass   127.0.0.1:9000;
  56.     #    fastcgi_index  index.php;
  57.     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  58.     #    include        fastcgi_params;
  59.     #}
  60.     # deny access to .htaccess files, if Apache's document root
  61.     # concurs with nginx's one
  62.     #
  63.     #location ~ /\.ht {
  64.     #    deny  all;
  65.     #}
  66. }
posted @ 2016-08-09 10:53  秋风落叶.  阅读(150)  评论(0编辑  收藏  举报