Apache2:禁止您无权访问此服务器上的/ dir /

我可以访问localhost但不能访问子目录index.html

我的default conf看起来像:

  ServerAdmin webmaster@localhost DocumentRoot /var/www  Options FollowSymLinks AllowOverride None   Allow from None Order allow,deny   Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all  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 

即使在允许对目录进行read/edit/write访问之后,它也会显示Forbidden错误。 在论坛中尝试了所有可能的方法,但没有奏效。 任何人都有解决方案。

在上面我尝试了一些sub directory访问:

  Allow from None Order allow,deny  

请建议我可能的解决方案。 谢谢!

让我们清除vhost:

  ServerAdmin webmaster@localhost DocumentRoot /var/www  Options FollowSymLinks AllowOverride None   Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all  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  

然后确保您设置正确的权限,如下所示:

 sudo adduser  www-data sudo chown -R www-data:www-data /var/www sudo chmod -R g+rw /var/www