Apache2:无法访问 Userdir - 禁止访问

问题描述 投票:0回答:2

我正在尝试在 Ubuntu 21.10 上运行 Apache 2.4。但是,我无法让 userdir 工作。除了重新安装 apache 之外,我做了所有可能的谷歌搜索。我通常是 Windows 用户,所以这让我抓狂。

我做了什么:

  • 启用 userdir.conf
  • 将文件夹 public_html 的权限设置为 777,并将所有权更改为 www-data
  • 添加 Require all granted to literally everywhere I can think:
    apache2.conf
    ,
    userdir.conf
    , and the config in
    sites-available
    to include
    <Directory /home/*/public_html >
     Require all granted
     AllowOverride All
     Options +Indexes 
   </Directory>   

然而,出于某种原因,当我试图去

ERROR 403: Forbidden
时,我所拥有的只是
http://localhost/~myusername
我可能会遗漏什么? 谢谢。

apache ubuntu http-status-code-403
2个回答
2
投票

原来是“因为路径的一个组成部分缺少搜索权限”。所以只需“chmod -R 755”我的整个主文件夹。可能不是很好的解决方案,但它仍然有效。


0
投票

检查您的主目录

$ ll -d /home/USER
drwx------. USER USER /home/USER

那就给

$ chmod 711 /home/USER
drwx--x--x. USER USER /home/USER

如果您仍然收到此错误,请确保 directories 设置为

chmod 755
但不要在所有文件和文件夹中运行它,只需运行:

find /home/USER -type d -exec chmod 755 {} \;

type -d
将只生成目录,并将它们更改为
755
...

© www.soinside.com 2019 - 2024. All rights reserved.