更改 Apache2 Web 目录。403 禁止

更改 Apache2 Web 目录。403 禁止

实际上我只是想将 Web 目录更改为 Ubuntu 中的另一个文件夹,但是 403 禁止错误却困扰着我。

我在 google 上尝试了很多方法来解决这个问题,但是这些解决方案都不能解决我的问题,比如更改文件夹的权限,

这是/etc/apache2/sites-enabled/000-default.conf文件(请参阅带有 的行的注释##############):

<VirtualHost *:80>

# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /usr/www 
############## (if I change to /var/www no forbidden)

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

这是/etc/apache2/apache2.conf文件

<Directory /usr/www/>
############## (if I change this to /var/www/ no problem.)
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

谁能帮我?

答案1

我建议您遵循这个解决方法,在大多数情况下它都不会出现问题。

如何将 apache /var/www 重定向到主目录并访问我的主目录中的所有目录和文件?

但请考虑一下,如果您对保留或受保护的目录进行更改,则必须授予适当的权限以允许所有人访问。

如果您在尝试此解决方法时遇到任何问题,请告知。

祝你好运!

相关内容