2014-10-03 20 views
1

我有一个简单的设置与Apache2.4和PHP-FPM,我试图启用+索引选项,但我得到404“文件未找到。尝试访问即使启用autoindex时也没有索引文件的文件夹时。ProxyPassMatch和选项+索引(mod_autoindex)

这里是我的虚拟主机的一部分:

#php 
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/fpm/fatal.sock|fcgi:// 

#super public directory with Indexes! 
<Location /pub> 
    Options +Indexes 
    IndexOptions +FancyIndexing 
</Location> 

当我尝试访问http://domain.com/pub/我希望看到我放在那里的文件列表,而是我得到错误404未找到。

我不知道这是从哪里来的,因为ProxyPassMatch不应该转发请求,因为在查询中没有.php,所以接下来是查找index.php的目录索引,它不存在(404),但为什么然后mod_autoindex不起作用?

当我删除ProxyPassMatch行时,autoindex工作得很好,我看到列出的文件夹内容。 任何想法?

回答

4

我找到了答案在这里http://blog.famillecollet.com/post/2014/03/28/PHP-FPM-and-HTTPD-2.4-improvement

As the ProxyPassMatch directive is evaluated as the very beginning of each request: 
-AddType (for MultiView) or DirectoryIndex directives are not usable 
-right management per directory is not available 
-each Alias directive needs another proxy rule 

The SetHandler directive, evaluated later, is much more flexible/usable. 

所以我改变了我的虚拟主机看起来像这一点,并摆脱了ProxyPassMatch指令。

<FilesMatch \.php$> 
    SetHandler "proxy:unix:/var/run/fpm/fatal.sock|fcgi://" 
</FilesMatch> 

注:该解决方案适用于Apache的2.4.9+

我不知道是否有任何性能差异和在什么方向?

+0

这可能是值得一提的是提出的方案还需要添加: SetHandler应用程序/ X的httpd - PHP源 作为链接的文章。 – dadasign 2015-01-19 09:30:59

+0

我怀疑这个版本的性能略差,因为正如您的报价所示,“ProxyPassMatch”跳过了几个步骤,例如目录权限管理。我怀疑这些差异是否足够重要。 – 2016-12-01 18:29:26