【问题标题】:How to setup nginx + php-fpm + wordpress for only certain URLs?如何仅为某些 URL 设置 nginx + php-fpm + wordpress?
【发布时间】:2009-08-08 02:16:43
【问题描述】:

我正在尝试让 nginx + php-fpm +wordpress 为我网站上的一些页面提供服务,同时充当其他页面的代理。

即:

host/foo -> 代理到另一个 www 服务器

host/bar -> wordpress(通过 fpm)

代理部分工作正常,但 nginx -> wordpress 部分只是不断重定向到根页面。

当我 strace php-fpm 进程时,我看到点击进入,wordpress 实际上会思考并加载所有内容,但在最后一秒它只是重定向回根页面。

在 google 上找不到任何关于如何在 php 端查看传入的 fastcgi 参数的信息。猜测从 nginx 发送的标头有问题,但我不知道如何查看所有发送的内容。 (strace 在这里不是很有帮助,因为它只给出前几个字节)

如果我通过 telnet 尝试并输入:

GET / HTTP/1.0 <CR><CR>

我得到了您所期望的正确内容(即:不重定向)。但从浏览器它会被重定向。

【问题讨论】:

  • 你能给我们看看 nginx 配置文件吗?
  • 很遗憾没有。该项目在很久以前就被放弃了,只支持使用 apache+mod_php,因为我们没有解决它。

标签: php wordpress nginx fastcgi


【解决方案1】:

在您的服务器设置下添加以下内容

# proxy the page to Apache listening on 127.0.0.1:80
location ^~ /foo {
    proxy_pass   http://127.0.0.1;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ /bar/.*\.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    include        fastcgi_params;
}

【讨论】:

    猜你喜欢
    • 2014-05-21
    • 2012-07-20
    • 2019-07-17
    • 2019-12-14
    • 1970-01-01
    • 2012-01-23
    • 2016-05-25
    • 2012-04-21
    • 1970-01-01
    相关资源
    最近更新 更多