如何使用自定义文档根在 Apache 2.4 中显示目录索引 [英] How to show Directory Index in Apache 2.4 with custom Document Root
问题描述
我在 Ubuntu 13.10 中的 Apache 2.4 中遇到问题.我尝试将文档根目录更改为/home/fandi/public_html并且一切正常.但是我尝试在我的 public_html/中创建文件夹我收到这样的错误:
i have problem in Apache 2.4 in Ubuntu 13.10. I try to change Document Root to /home/fandi/public_html And all working fine. But i try to create folder in my public_html/ i get an error like this :
[Sat Jan 25 10:59:50.149441 2014] [autoindex:error] [pid 1093] [client 127.0.0.1:39901] AH01276: Cannot serve directory /home/fandi/public_html/report_php/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
我必须创建文件 index.html
、index.php
和其他 index.xxx
文件.
I must create file index.html
, index.php
and other index.xxx
file.
默认情况下,它必须显示目录索引.如何启用目录索引?
In default it must show Directory Index. How to enable Directory Index?
这是我的文件 000-default.conf
:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/fandi/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/fandi/public_html">
Options All
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
请帮忙,先谢谢^^
推荐答案
原来你需要在 Apache 2.4 中禁用 DirectoryIndex 才能获得自动索引.
Turns out you need to disable DirectoryIndex in Apache 2.4 to get auto Indexes.
DirectoryIndex disabled
Options Indexes
当 DirectoryIndex 未禁用时,自动索引不起作用,如果您使用 fastcgi/php-fpm,apache 将发送 403 Forbidden 或 404 File not found.
When DirectoryIndex is not disabled, auto index does not work and apache sends either a 403 Forbidden or a 404 File not found if you use fastcgi/php-fpm.
以下是相应的错误日志行(用于搜索):
Here are the corresponding error log lines (for search purposes):
[authz_core:error] client denied by server configuration:
[proxy_fcgi:error] Got error 'Primary script unknown\n'
这篇关于如何使用自定义文档根在 Apache 2.4 中显示目录索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!