2014-10-03 66 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