当前位置: 首页 > 知识库问答 >
问题:

Apache 2.4。6 mod_proxy_fcgi和PHP-FPM返回404错误

平航
2023-03-14

我有PHP 5.3.3与PHP-FPM在172.17.0.163:20533运行。我用nginx和cgi-fcgi测试了它:

$ SCRIPT_FILENAME=/www/localhost/test.php REQUEST_METHOD=GET cgi-fcgi -bind -connect 172.17.0.163:20533 

返回

X-Powered-By: PHP/5.3.3
Content-type: text/html

hello, it works!

所以,PHP-FPM正在工作。

不幸的是,Apache 2.4在PHP-FPM方面存在一些问题:

<VirtualHost *>
    UseCanonicalName Off
    VirtualDocumentRoot "/www/%0"

    RewriteEngine On
    RewriteRule ^/(.*\.php(/.*)?)$ fcgi://172.17.0.163:20533/www/%{SERVER_NAME}/$1 [P]
</VirtualHost>

正在打开http://localhost/test。php返回一个“404未找到”错误。非PHP文件正在工作。查看apache错误日志,一切看起来都很好。

[Fri Nov 15 18:53:00.426776 2013] [mpm_event:info] [pid 1959:tid 140474380953408] AH00490: Server built: Nov 13 2013 14:23:31
[Fri Nov 15 18:53:00.426787 2013] [core:notice] [pid 1959:tid 140474380953408] AH00094: Command line: '/usr/local/sbin/httpd'
[Fri Nov 15 18:53:00.426917 2013] [proxy:debug] [pid 3028:tid 140474380953408] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Fri Nov 15 18:53:00.426950 2013] [proxy:debug] [pid 3028:tid 140474380953408] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Fri Nov 15 18:53:00.427010 2013] [proxy:debug] [pid 3028:tid 140474380953408] proxy_util.c(1769): AH00930: initialized pool in child 3028 for (*) min=0 max=25 smax=25
[Fri Nov 15 18:53:00.427101 2013] [proxy:debug] [pid 3030:tid 140474380953408] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Fri Nov 15 18:53:00.427421 2013] [proxy:debug] [pid 3029:tid 140474380953408] proxy_util.c(1694): AH00925: initializing worker proxy:reverse shared
[Fri Nov 15 18:53:00.427445 2013] [proxy:debug] [pid 3029:tid 140474380953408] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Fri Nov 15 18:53:00.427488 2013] [proxy:debug] [pid 3029:tid 140474380953408] proxy_util.c(1769): AH00930: initialized pool in child 3029 for (*) min=0 max=25 smax=25
[Fri Nov 15 18:53:00.427129 2013] [proxy:debug] [pid 3030:tid 140474380953408] proxy_util.c(1734): AH00927: initializing worker proxy:reverse local
[Fri Nov 15 18:53:00.428326 2013] [proxy:debug] [pid 3030:tid 140474380953408] proxy_util.c(1769): AH00930: initialized pool in child 3030 for (*) min=0 max=25 smax=25
[Fri Nov 15 18:53:01.627599 2013] [rewrite:trace2] [pid 3028:tid 140474150618880] mod_rewrite.c(468): [client 172.17.42.1:57951] 172.17.42.1 - - [localhost/sid#7fc2bd82e7f8][rid#7fc2bd7a10a0/initial] init rewrite engine with requested uri /test.php
[Fri Nov 15 18:53:01.627664 2013] [rewrite:trace3] [pid 3028:tid 140474150618880] mod_rewrite.c(468): [client 172.17.42.1:57951] 172.17.42.1 - - [localhost/sid#7fc2bd82e7f8][rid#7fc2bd7a10a0/initial] applying pattern '^/(.*\\.php(/.*)?)$' to uri '/test.php'
[Fri Nov 15 18:53:01.627718 2013] [rewrite:trace2] [pid 3028:tid 140474150618880] mod_rewrite.c(468): [client 172.17.42.1:57951] 172.17.42.1 - - [localhost/sid#7fc2bd82e7f8][rid#7fc2bd7a10a0/initial] rewrite '/test.php' -> 'fcgi://172.17.0.163:20533/www/localhost/test.php'
[Fri Nov 15 18:53:01.627747 2013] [rewrite:trace2] [pid 3028:tid 140474150618880] mod_rewrite.c(468): [client 172.17.42.1:57951] 172.17.42.1 - - [localhost/sid#7fc2bd82e7f8][rid#7fc2bd7a10a0/initial] forcing proxy-throughput with fcgi://172.17.0.163:20533/www/localhost/test.php
[Fri Nov 15 18:53:01.627759 2013] [rewrite:trace1] [pid 3028:tid 140474150618880] mod_rewrite.c(468): [client 172.17.42.1:57951] 172.17.42.1 - - [localhost/sid#7fc2bd82e7f8][rid#7fc2bd7a10a0/initial] go-ahead with proxy request proxy:fcgi://172.17.0.163:20533/www/localhost/test.php [OK]
[Fri Nov 15 18:53:01.627776 2013] [proxy_fcgi:trace1] [pid 3028:tid 140474150618880] mod_proxy_fcgi.c(90): [client 172.17.42.1:57951] canonicalising URL //172.17.0.163:20533/www/localhost/test.php
[Fri Nov 15 18:53:01.627776 2013] [proxy_fcgi:debug] [pid 3028:tid 140474150618880] mod_proxy_fcgi.c(120): [client 172.17.42.1:57951] AH01060: set r->filename to proxy:fcgi://172.17.0.163:20533/www/localhost/test.php
[Fri Nov 15 18:53:01.628070 2013] [proxy:trace2] [pid 3028:tid 140474150618880] proxy_util.c(1857): [client 172.17.42.1:57951] *: found reverse proxy worker for fcgi://172.17.0.163:20533/www/localhost/test.php
[Fri Nov 15 18:53:01.628082 2013] [proxy:debug] [pid 3028:tid 140474150618880] mod_proxy.c(1100): [client 172.17.42.1:57951] AH01143: Running scheme fcgi handler (attempt 0)
[Fri Nov 15 18:53:01.628096 2013] [proxy_fcgi:debug] [pid 3028:tid 140474150618880] mod_proxy_fcgi.c(944): [client 172.17.42.1:57951] AH01076: url: fcgi://172.17.0.163:20533/www/localhost/test.php proxyname: (null) proxyport: 0
[Fri Nov 15 18:53:01.628107 2013] [proxy_fcgi:debug] [pid 3028:tid 140474150618880] mod_proxy_fcgi.c(954): [client 172.17.42.1:57951] AH01078: serving URL //172.17.0.163:20533/www/localhost/test.php
[Fri Nov 15 18:53:01.628134 2013] [proxy:debug] [pid 3028:tid 140474150618880] proxy_util.c(2020): AH00942: FCGI: has acquired connection for (*)
[Fri Nov 15 18:53:01.628147 2013] [proxy:debug] [pid 3028:tid 140474150618880] proxy_util.c(2072): [client 172.17.42.1:57951] AH00944: connecting //172.17.0.163:20533/www/localhost/test.php to 172.17.0.163:20533
[Fri Nov 15 18:53:01.628224 2013] [proxy:debug] [pid 3028:tid 140474150618880] proxy_util.c(2194): [client 172.17.42.1:57951] AH00947: connected /www/localhost/test.php to 172.17.0.163:20533
[Fri Nov 15 18:53:01.628248 2013] [proxy:trace2] [pid 3028:tid 140474150618880] proxy_util.c(2446): FCGI: fam 2 socket created to connect to *
[Fri Nov 15 18:53:01.629453 2013] [proxy_fcgi:trace4] [pid 3028:tid 140474150618880] util_script.c(521): [client 172.17.42.1:57951] Headers from script 'test.php':
[Fri Nov 15 18:53:01.629552 2013] [proxy_fcgi:trace4] [pid 3028:tid 140474150618880] util_script.c(522): [client 172.17.42.1:57951]   Status: 404 Not Found
[Fri Nov 15 18:53:01.629583 2013] [proxy_fcgi:trace1] [pid 3028:tid 140474150618880] util_script.c(599): [client 172.17.42.1:57951] Status line from script 'test.php': 404 Not Found
[Fri Nov 15 18:53:01.629595 2013] [proxy_fcgi:trace4] [pid 3028:tid 140474150618880] util_script.c(522): [client 172.17.42.1:57951]   X-Powered-By: PHP/5.3.3
[Fri Nov 15 18:53:01.629608 2013] [proxy_fcgi:trace4] [pid 3028:tid 140474150618880] util_script.c(522): [client 172.17.42.1:57951]   Content-type: text/html
[Fri Nov 15 18:53:01.629680 2013] [proxy:debug] [pid 3028:tid 140474150618880] proxy_util.c(2035): AH00943: FCGI: has released connection for (*)

似乎mod_proxy_fcgi没有正确发送脚本路径?!有人有主意吗?

2013年11月16日更新

我用Apache 2.2.25和mod_fastcgi2.4.6测试了它:

<VirtualHost *>
    UseCanonicalName Off
    VirtualDocumentRoot "/www/%0"

    AddHandler php5-fastcgi .php
    FastCgiExternalServer /www/localhost -host 172.17.0.163:20533
</VirtualHost>

工作起来很有魅力。我猜是Apache2.4。6带有mod_proxy_的fcgi有缺陷。

更新17十一月2013

我用Apache 2.4.6和mod_proxy_fcgi以及PHP 5.4.21测试了它。它工作。因此,PHP 5.3.3以及Apache 2.4.6和mod_proxy_fcgi似乎存在问题。

共有1个答案

赵骏奇
2023-03-14

使用PHP5.3。27解决了所有问题。

 类似资料:
  • 运行Nginx 1.17的Digital Ocean Ubuntu18.04 VPS。10 PHP-FPM7.3。我不知道如何正确运行PHP文件(其他一切都正常运行)php文件生成Nginx的404未找到页面。Nginx错误日志仅显示“信号处理已启动”每次更改后,我都会重新启动nginx fpm。我已经研究了几乎所有与此相关的StackOverflow问题,并尝试了各种不同的配置。如果您能提供任何

  • 首先,我尝试在Debian Jessie(测试)机器上为Apache 2.4、mod_proxy_fcgi和PHP-FPM设置一个基本配置。 打开时一切正常。php文件。 然而,如果我为PHP-FPM激活chroot,我只会得到一个“未找到文件”我的浏览器中的消息 。 apache2的部分内容。形态 /var/ww/html的内容 /etc/php5/fpm/pool.d/www部分内容* ...

  • My/etc/php-fpm.d/www.conf 我的nginx/etc/nginx/conf.d/default.conf

  • JSoup-1.8.1 尝试{ Document Document=Jsoup.connect(url.get(); 返回Document.getElementsByTag(“title”).text(); }catch(异常e){ System.out.println(e); 返回null; } org.jsoup.HttpStatusExc0019: HTTP错误获取URL。状态=404, U

  • 问题内容: 我是WordPress设计师,我为自己的主题之一开发了联系表格,该主题已通过jQuery验证。 请检查下面的代码,然后阅读下面的注释。 笔记: sendEmail.php是使用PHPmailer类发送电子邮件的正确脚本。 templatePath变量具有如下所示的完整模板路径的值:http : //somedomain.com/wp-content/themes/themename 上

  • 我有一个运行在后端的Node/Express服务器和一个react前端,我正在尝试制作最简单的API——但无论我做什么,我似乎都在post请求中遇到了404错误。我已尝试将代理添加到包中。json,删除代理并在地址i中包含端口。。Ehttp://localhost:5000/createaccount,包括http://localhost:5000只需在post请求中使用“/createaccou