Apache ProxyPass工作者名称太长

我将我的php文件传递给我的Apache .conf文件中的php5-fpm,但是我在重新启动Apache服务器时收到错误消息:

ProxyPass工作人员名称(fcgi://127.0.0.1:9000 / home / averyverylong / directoryname /到/ www / working /目录/ $ 1)太长。

我通过php文件传递给php-fpm:

ProxyPassMatch ^/(.*\.php(/.*)?)$ \ fcgi://127.0.0.1:9000/home/averyverylong/directoryname/tothe/www/working/directory/$1 

显然,如果我缩短目录名称,它工作正常。 但是,这不是一个真正的select。

运行:Apache / 2.4.10(Ubuntu 14.04)PHP5-FPM

我很困惑这一点,花了整整一天的时间,试图找出解决办法。 我的服务器技能不是最强的,任何反馈将不胜感激。

作为一种解决方法,您可以使用较短的名称创build一个符号链接到更长的path。 例如:

 ln -s /home/averyverylong/directoryname/tothe/www/working/directory \ /var/www/html/shortcut 

然后使用

 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/shortcut 

一个替代(在我看来,更优雅)的解决scheme将是使用RewriteEngine,正如在这个Apache错误报告https://bz.apache.org/bugzilla/show_bug.cgi?id=53218

 # This directive must come before the following one in order # block access to arbitrary URIs on the origin server! # As an alternative one can also use "RewriteRule /UNUSED - [F]" ProxyPass /UNUSED ! # Configure a connection pool for the origin server # http://myserver.example.org:9081 ProxyPass /UNUSED fcgi://127.0.0.1:9000 RewriteEngine On # Proxy "/long" to a long URI on the origin server, # [P] flag at end of line is important RewriteRule ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/home/averyverylong/directoryname/tothe/www/working/directory/$1 [P] 

这使您可以继续使用相同的文件结构,而无需在任何地方手动创build符号链接(这在Windows机器上也无法使用)。 我相信,在未来的Apache版本中,工作人员名称限制正在提出,但现在这种解决方法应该能够为您提供所需的结果。

根据apache> = 2.4.9中的symfony文档,你可以使用

 <FilesMatch \.php$> # 2.4.10+ can proxy to unix socket # SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/" # Else we can just use a tcp socket: SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch> 

http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html#php-fpm-with-apache-2-2
https://serversforhackers.com/video/apache-and-php-fpm

Bug提交给Ubuntu。 请指出您受到影响并要求更新Trusty。 获得修复到稳定的版本将需要来自社区的一些input。

https://bugs.launchpad.net/apache2/+bug/1668474