简体   繁体   English

Apache无法访问主文件夹中的文件

[英]Apache can't access files in home folder

I am running Apache with PHP on an Ubuntu server. 我在Ubuntu服务器上使用PHP运行Apache。 I have some user folders that I want Apache to serve up. 我有一些用户文件夹,我希望Apache提供服务。 Each one is a unique subdomain: 每个都是一个独特的子域:

/home/alec/www
/home/bob/www
/home/carl/www

I already have the configuration files setup in the sites-available/ folder and enabled them. 我已经在sites-available /文件夹中设置了配置文件并启用了它们。 However, when I try to access the sites in my browser, I'm getting a 403 error in all of them. 但是,当我尝试访问浏览器中的网站时,我在所有网站中都收到403错误。 Apache is saying that it's unable to access the root directory. Apache说它无法访问根目录。

All folders and files (including the /home folder) have www-data as the group, the user's name as the owner (except for home and www, which have root set as the owner) and 755 permissions. 所有文件夹和文件(包括/ home文件夹)都有www-data作为组,用户名作为所有者(除了home和www,其中root设置为所有者)和755权限。

Any idea what I'm doing wrong? 知道我做错了什么吗?

Try to add Apache authorization to access the locations. 尝试添加Apache授权以访问位置。 For Apache > 2.4 : 对于Apache> 2.4:

<Directory /path/to/public/website/> Require all granted ... </Directory>

Also, if you added configuration override through htaccess files with : 此外,如果您通过htaccess文件添加了配置覆盖:

<Directory /path/to/public/website/> AllowOverride All ... </Directory>

you may check the htaccess file in the folder you try to access. 您可以检查您尝试访问的文件夹中的htaccess文件。

As a workaround , you could also make symbolic links from the default Apache folder to your site folder. 作为解决方法 ,您还可以创建从默认Apache文件夹到站点文件夹的符号链接。

 sudo ln -s /var/www/htlm/mysite /path/to/mysite

You should add your current configuration and Apache version to the question. 您应该将当前配置和Apache版本添加到问题中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM