更改 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重定向到主目錄並存取我的主目錄中的所有目錄和檔案?

但請注意,如果您對保留或受保護的目錄進行更改,則必須授予適當的權限才能允許每個人存取。

如果您在嘗試使用此解決方法時遇到任何問題,請告知。

祝你好運!

相關內容