Debian 7.8上的Apache 2.4.9 – 不允许使用.htaccess选项

我是pipe理运行在Debian 7.8上的Apache 2.4.9 Web服务器的团队的一部分。 我们遇到了一个用户网站的问题:

www.example.com/~user

当我们尝试访问这个URL时,一个页面加载了以下内容:

内部服务器错误

服务器遇到内部错误或configuration错误,无法完成您的请求。

请联系服务器pipe理员webmaster @ localhost,并告知他们错误发生的时间,以及您可能已经犯的错误。

有关此错误的更多信息可能在服务器错误日志中可用。 Apache / 2.2.22(Debian)服务器,位于www.cpdee.ufmg.br端口80

而在/var/log/apache2/error.log我find这个:

 [Fri Apr 03 11:36:36 2015] [alert] [client 179.214.195.80] /home/web/user/.htaccess: Options not allowed here 

如果我再查看/home/web/user/.htacces文件的内容,那么就是这个configuration行:

 Options -Indexes 

经过快速的研究,我觉得这个问题与Apache的虚拟主机configuration有关。 具体来说, 本教程指出可以通过在/ etc / apache2 / sites-enabled / 000-default的“AllowOverride”列表中添加“Options”来解决该问题,如下所示:

 <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride FileInfo Options Order allow,deny allow from all </Directory> 

这个文件只是一个到/etc/apache2/sites-available/default文件的链接,在我的情况下,这个文件看起来有些杂乱:

 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride Options </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride Options Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

正如所build议的,我添加了OptionsAllowOverried列表(对于每个<Directory> ... </Directory> “标签”我在那里find)。 然后我启用了这些修改,并用这组命令重新加载了Apache:

 a2ensite default /etc/init.d/apache2 reload 

即使有了这些变化,我仍然有同样的问题,我真的不知道什么是错的。 有人可以帮我吗?

检查userdir.conf更具体的configurationuserdir.conf覆盖您在<Directory />指定的设置。 在/etc/apache2/mods-enabled/userdir.conf中指定了userdir的Directory指令,默认是:

 <IfModule mod_userdir.c> UserDir public_html UserDir disabled root <Directory /home/*/public_html> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec <Limit GET POST OPTIONS> Order allow,deny Allow from all </Limit> <LimitExcept GET POST OPTIONS> Order deny,allow Deny from all </LimitExcept> </Directory> </IfModule> 

所以你应该在这里添加OptionsAllowOverride指令。

(也许你的目录是<Directory /home/web/*/> )。