fan*_*aid 19 webserver apache2.4
我在Ubuntu 13.10中的Apache 2.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
Run Code Online (Sandbox Code Playgroud)
我必须创建文件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
Run Code Online (Sandbox Code Playgroud)
请帮助,谢谢^^之前
小智 10
事实证明,您需要在Apache 2.4中禁用DirectoryIndex以获取自动索引.
DirectoryIndex disabled
Options Indexes
Run Code Online (Sandbox Code Playgroud)
如果未禁用DirectoryIndex,则自动索引不起作用,如果使用fastcgi/php-fpm,则apache会发送403 Forbidden或404 File not found.
以下是相应的错误日志行(用于搜索目的):
[authz_core:error] client denied by server configuration:
[proxy_fcgi:error] Got error 'Primary script unknown\n'
Run Code Online (Sandbox Code Playgroud)
Options All <--turn on all options
Options Indexes FollowSymLinks <--- replace previously set options with these two
Run Code Online (Sandbox Code Playgroud)
第二行是多余的,因为您已经使用第一行打开了所有选项,并且因为这两个选项没有前缀+
,它们实际上All
只使用这两个单独的选项来替换整个选项列表启用集.
我设法让它发挥作用
基本上似乎Apache2.4没有将DocumentRoot中的设置转移到虚拟主机,除非虚拟主机是DocumentRoot的子文件夹,就像以前的版本一样.哪种有意义,但应该记录变更,但事实并非如此.
我的意思是,在你的httpd.conf中你将拥有(这是一个OS X):
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options +Indexes +FollowSymLinks
# etc
</Directory>
Run Code Online (Sandbox Code Playgroud)
然后在你的extra/httpd-vhosts.conf中
<VirtualHost *:80>
DocumentRoot "/pth/to/somewhere/completely/different"
ServerName my-virtual-host.dev
ErrorLog "/private/var/log/apache2/my-virtual-host.dev-error_log"
CustomLog "/private/var/log/apache2/my-virtual-host.dev-access_log" common
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
VH用于继承所有设置 - 如果它不是子文件夹,则不再存在.所以你需要做的是复制并粘贴VH中的设置(<directory
如果你在同一个地方有很多VH,你可以创建另一个)
<VirtualHost *:80>
DocumentRoot "/pth/to/somewhere/completely/different"
ServerName my-virtual-host.dev
ErrorLog "/private/var/log/apache2/my-virtual-host.dev-error_log"
CustomLog "/private/var/log/apache2/my-virtual-host.dev-access_log" common
<Directory "/pth/to/somewhere/completely/different">
Options +Indexes
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
这是魔法的+索引.
小智 5
我对Centos 7.2和apache 2.4也有同样的问题.
在新安装中,问题很可能是由于welcome.conf
在每个位置禁用选项索引引起的:
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
Run Code Online (Sandbox Code Playgroud)
在每次Apache升级时都会恢复此文件,然后您应该注释或删除以前的行.
归档时间: |
|
查看次数: |
55663 次 |
最近记录: |