TypechoJoeTheme

Yuuuuuu

lnmp部署typecho出现404解决

安装完typecho只有首页能访问,访问其它页页面报404错误。
问题在于typecho需要pathinfo功能,nginx需要配置才能支持此功能。
所以如果想要启用pathinfo,需要注释掉“try_files $uri =404;”这行代码。
所以,LNMP1.1安装typecho后404问题解决办法就是:
/usr/local/nginx/conf/vhost/下找到你的typecho站点配置文件(文件名类似xxxxx.conf),然后:

  1. 确保有“include typecho.conf;”这么一行,并且没有被“#”号注释;
  2. 用“#”号注释“try_files $uri =404;”这一行;
  3. 取消“#include pathinfo.conf;”这一行前面的的“#”号;
    修改正确的话,typecho站点conf配置文件看起来如下:

    server {
     listen       80;
     server_name  localhost;
     index        index.html index.htm index.php;
     root         /home/wwwroot/function;
    
     location / {
         try_files $uri $uri/ /index.php$is_args$args;
     }
    
     location ~ \.php(\/.*)*$ {
         #try_files      $uri = 404;
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
         fastcgi_pass   unix:/var/run/php-fpm/php5-fpm.sock;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include        fastcgi_params;
     }
    }

在某些老版本的php里面,可能还要打开/etc/php.ini里的cgi.fix_pathinfo

cgi.fix_pathinfo = 1

然后重启nginx

service nginx restart
赞(0)
评论 (0)