子文件夹+ debian配置中的nginx + wordpress

时间:2018-04-02 20:09:40

标签: php wordpress nginx fpm

在域名的子文件夹中,我想安装一个wordpress博客。我用nginx。访问博客的URL应如下所示:example.com/blog

网站配置如下:

server {
        listen 80;
        listen [::]:80;
        root /var/www/example.com/html; 
        index index.php index.html index.htm index.nginx-debian.html;   
        server_name example.com www.example.com;

        location /blog {
                alias /var/www/example.comblog/html;
                index index.php;
                try_files $uri $uri/ /blog/index.php?q=$uri&$args;
        }

        location ~ /blog/.+\.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        location ~ /\.ht {
                deny all;
        }
}
  • wordpress文件位于文件夹中 /var/www/example.comblog/html。访问example.com/blog时, 浏览器显示404错误。

  • /etc/php5/fpm/php.ini我改编了这个:cgi.fix_pathinfo=0

  • nginx版本:nginx / 1.6.2

  • /var/log/nginx/error.log没有显示任何有趣的内容

更新1:

将错误记录设置为调试后,(以及其他)显示以下行。也许这会有所帮助:

open index "/var/www/example.comblog/html/index.php"
internal redirect: "/blog/index.php?"
rewrite phase: 1
test location: "/blog"
test location: ~ "/blog/.+\.php$"
using configuration "/blog/.+\.php$"
http script var: "/blog/index.php"
trying to use file: "/blog/index.php" "/var/www/example.com/html/blog/index.php"

内部重定向似乎不正确?在最后一行,应该是/var/www/example.comblog/html/blog/index.php而不是/var/www/example.com/html/blog/index.php。我怀疑这是404的原因。因为index.php上不存在/var/www/example.com/html/blog/index.php

更新2:

好吧似乎有一个 long standing issue with using alias together with try_files

0 个答案:

没有答案