我正在尝试配置一个需要在根目录中受密码保护的 apache 虚拟主机。
所以我创建了一个 .htpasswd 文件(带有 sha 密码)并配置了 .htaccess 文件。不管我做什么,在网页上我都会收到错误 500(内部服务器错误),在 error.log 中我看到了这个:
/var/www/ninja/www/.htaccess: deny not allowed here
Run Code Online (Sandbox Code Playgroud)
或者如果我将拒绝排除在 .htaccess 之外:
AuthUserFile not allowed here
Run Code Online (Sandbox Code Playgroud)
.htpasswd 和 .htaccess 文件对于 apache 都是可读的,并且被设置为 www-data 用户和组。我也尝试将这些规则添加到虚拟主机配置文件中,但这也没有奏效。
你能帮我一下吗?
谢谢!
配置文件阿帕奇:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName ninja
DocumentRoot /var/www/ninja/www
ServerAlias ninja
<Directory /var/www/ninja/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo Indexes
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 …
Run Code Online (Sandbox Code Playgroud)