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

相關文章
相關標籤/搜索