我在Ubuntu 13.10的Apache2.4中遇到了问题。我尝试将Document Root更改为/home/fandi/public_html,一切正常。但是我尝试在public_html中创建文件夹,得到如下错误:
[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
文件。
默认情况下,它必须显示目录索引。如何启用目录索引?
这是我的文件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
请帮帮忙,谢谢您之前^^
发布于 2014-08-01 20:34:24
原来你需要在Apache2.4中禁用DirectoryIndex才能获得自动索引。
DirectoryIndex disabled
Options Indexes
当DirectoryIndex未被禁用时,自动索引不起作用,如果您使用fastcgi/php-fpm,则apache会发送403禁止或404未找到的文件。
以下是相应的错误日志行(用于搜索目的):
[authz_core:error] client denied by server configuration:
[proxy_fcgi:error] Got error 'Primary script unknown\n'
发布于 2014-01-25 12:11:20
Options All <--turn on all options
Options Indexes FollowSymLinks <--- replace previously set options with these two
第二行是多余的,因为您已经用第一行打开了所有选项,而且由于这两个选项没有以+
为前缀,所以它们实际上只用这两个单独的选项替换了整个选项列表启用了All
的集合。
发布于 2016-08-31 06:34:39
我在Centos 7.2和Apache2.4上也遇到了同样的问题。
在新安装中,该问题很可能是由禁用每个位置的选项索引的welcome.conf
引起的:
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
此文件会在每次Apache升级时恢复,然后您应该注释或删除前面的行。
https://stackoverflow.com/questions/21346486
复制相似问题