linux中安装typecho的pathinfo配置

最近,我安装typecho,安装完以后发现,只有首页可以访问,其余的页面报404错误php

后来发现时nginx默认状况下不支持pathinfo模式,因而我查找一下资料。终于获得解决。css

个人nginx.conf配置以下:html

server
{
 listen       80;
 server_name  47.93.101.33;
 server_name  www.xialan.tech;
 index  index.php index.html;
 root  /var/www/html/typecho/build;

 location ~ .*\.php(\/.*)*$
 {
  #fastcgi_pass  unix:/tmp/php-cgi.sock;
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index index.php;
  #  limit_conn one 20;
 #设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,
 #后面不须要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,因此必须在加载fastcgi.conf以前设置
 # fastcgi_split_path_info  ^(.+\.php)(/.*)$;
 # fastcgi_param  PATH_INFO $fastcgi_path_info;
 # fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
 set $path_info "";
 set $real_script_name $fastcgi_script_name;
 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
    set $real_script_name $1;
    set $path_info $2;
  }
 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
 fastcgi_param SCRIPT_NAME $real_script_name;
 fastcgi_param PATH_INFO $path_info;

# include fastcgi_params;
     include fastcgi.conf;
 }

 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
 {
 expires     3d;
 }

 location ~ .*\.(js|css)?$
 {
 expires     1h;
 }

}

参考:http://docs.typecho.org/serversnginx

相关文章
相关标签/搜索