dqsot35145 2015-08-02 11:31
浏览 60

NGINX try_files奇怪的行为

I'm currently trying to integrate WordPress with an existing Laravel codebase.

I can access files in /var/www/src/blog directly, for instance, site.com/blog/example.php but I'm not able to access the index.php via mysite.com/blog/, so I'm unsure whether the issue is specific to my NGINX config or wordpress itself. Any help is much appreciated.

server {
    listen 80;
    charset utf-8;
    error_log /var/log/nginx/error.log debug;
    index index.php index.html;
    server_name ha_laravel.com;
    sendfile off;

    location / {
      try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ /blog/(.*)$ {
        root /var/www/src/blog;
        try_files /$1 /$1/ /index.php?$args;
        location ~ .*\/(.*php)$ {
                try_files /$1 /index.php?$args;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root/$1;
                fastcgi_cache off;
        }
    }
}

Error Log

2015/08/02 11:20:15 [debug] 24131#0: *1529 test location: "/"
2015/08/02 11:20:15 [debug] 24131#0: *1529 test location: ~ "/blog/(.*)$"
2015/08/02 11:20:15 [debug] 24131#0: *1529 test location: ~ ".*\/(.*php)$"
2015/08/02 11:20:15 [debug] 24131#0: *1529 using configuration "/blog/(.*)$"

2015/08/02 11:06:55 [debug] 24284#0: *1535 test location: "/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 test location: ~ "/blog/(.*)$"
2015/08/02 11:06:55 [debug] 24284#0: *1535 test location: ~ ".*\/(.*php)$"
2015/08/02 11:06:55 [debug] 24284#0: *1535 using configuration "/blog/(.*)$"

Note: I omitted for readability, but the following was logged several time, presumably I somehow caused a loop?

internal error.
2015/08/02 11:06:55 [debug] 24284#0: *1535 http cl:-1 max:1048576
2015/08/02 11:06:55 [debug] 24284#0: *1535 rewrite phase: 3
2015/08/02 11:06:55 [debug] 24284#0: *1535 post rewrite phase: 4
2015/08/02 11:06:55 [debug] 24284#0: *1535 generic phase: 5
2015/08/02 11:06:55 [debug] 24284#0: *1535 generic phase: 6
2015/08/02 11:06:55 [debug] 24284#0: *1535 generic phase: 7
2015/08/02 11:06:55 [debug] 24284#0: *1535 access phase: 8
2015/08/02 11:06:55 [debug] 24284#0: *1535 access phase: 9
2015/08/02 11:06:55 [debug] 24284#0: *1535 post access phase: 10
2015/08/02 11:06:55 [debug] 24284#0: *1535 try files phase: 11
2015/08/02 11:06:55 [debug] 24284#0: *1535 http script copy: "/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 http script capture: ""
2015/08/02 11:06:55 [debug] 24284#0: *1535 trying to use file: "/" "/var/www/src/blog/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 http script copy: "/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 http script capture: ""
2015/08/02 11:06:55 [debug] 24284#0: *1535 trying to use dir: "/" "/var/www/src/blog/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 try file uri: "/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 content phase: 12
2015/08/02 11:06:55 [debug] 24284#0: *1535 open index "/var/www/src/blog/index.php"
2015/08/02 11:06:55 [debug] 24284#0: *1535 internal redirect: "/index.php?"
2015/08/02 11:06:55 [debug] 24284#0: *1535 rewrite phase: 1
2015/08/02 11:06:55 [debug] 24284#0: *1535 test location: "/"
2015/08/02 11:06:55 [debug] 24284#0: *1535 test location: ~ "/blog/(.*)$"
2015/08/02 11:06:55 [debug] 24284#0: *1535 using configuration "/"

Full log (in debug mode): http://pastebin.com/ZdZj40M1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
    • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
    • ¥15 opencv图像处理,需要四个处理结果图
    • ¥15 无线移动边缘计算系统中的系统模型
    • ¥15 深度学习中的画图问题
    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了