为什么 Dropbox 会在 Ubuntu 上导致 apache2 虚拟主机路径的路径 + 权限问题?

idi*_*mer 1 dropbox virtualhost apache-2.2

我正在尝试在我的 64 位 12.04 Ubuntu 机器上创建一个开发环境,而我最该死的时间是让虚拟主机工作。我终于弄清楚问题是什么,但我真的无法理解。

我将虚拟主机的文档根目录设置在我的主目录中——即:

/home/robert/Dropbox/www/personville

当我在浏览器中访问 www.personvillepress2.com 时,我得到

Forbidden 您无权访问 / 在此服务器上。Apache/2.2.22 (Ubuntu) 服务器在 www.personvillepress2.com 端口 80

在日志中,我看到

[Sat Jun 16 09:55:25 2012] [crit] [client 127.0.0.1] (13)Permission denied: /home/robert/Dropbox/.htaccess pcfg_openfile: 无法检查 htaccess 文件,确保它是可读的

我将文档根目录移动到 /home/robert/www/personville

相应地修改虚拟主机设置,重新加载,然后突然一切正常!这很糟糕,因为我想将所有源保存在我的 Dropbox 文件夹中以进行备份。

我对 dropbox 文件夹的权限似乎很正常:

robert@kundera-linux:~/Dropbox$ ls -al
total 1036
drwx------ 29 robert robert   4096 Jun 15 09:11 .
drwxr-xr-x 60 robert robert   4096 Jun 15 21:15 ..
-rw-rw-r--  1 robert robert     29 Jun 15 09:11 .dropbox
drwxrwxr-x  2 robert robert 262144 Jun 13 05:22 .dropbox.cache
drwxrwxr-x  5 robert robert   4096 Jun  9 00:00 www
Run Code Online (Sandbox Code Playgroud)

没有符号链接或异常严格的权限。此外,我没有看到任何可能导致任何问题的 .htaccess 问题(为什么 apache2 会关心文档根目录上方的 .htaccess 权限问题?)

对于如何以一种让我将源文件保存在 Dropbox 中的方式解决此问题的任何想法,我表示感谢。

不工作的虚拟主机文件如下:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
ServerName  personvillepress2.com
      ServerAlias www.personvillepress2.com
    # DocumentRoot /var/www
    DocumentRoot /home/robert/Dropbox/www/personville

    <Directory /home/robert/Dropbox/www/personville>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>


    ErrorLog ${APACHE_LOG_DIR}/personvillepress2error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

更新:我看到其他人以前遇到过这个问题。 /sf/ask/662203671/

我并不真正担心这里的安全性——这是一个开发箱;我主要担心其他机器的备份和访问。我正在考虑使用 git 部署到实时站点,所以我想要的只是一种备份本地数据的方式。任何人都可以提出解决方案吗?谢谢。

use*_*517 5

在我看来,这是一个简单的权限问题。在 Ubuntu 上,Apache 作为用户www-data组运行www-data。正如我们从您的目录列表中看到的,您的目录的权限~/Dropbox(通过.)是drwx------700。因此 Apache aswww-data:www-data被拒绝访问。

chmod 755 ~/Dropbox
Run Code Online (Sandbox Code Playgroud)

可能会解决眼前的问题。通常,您需要提供o:rx目录o:r权限和文件权限,以允许 Apache 访问文件。