下载 Drupal 时权限被拒绝

下载 Drupal 时权限被拒绝
 /var/www$ wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz

这导致:

    --2012-02-08 21:20:17--  http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz
Resolving ftp.drupal.org... 64.50.233.100, 64.50.236.52
Connecting to ftp.drupal.org|64.50.233.100|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2728271 (2.6M) [application/x-gzip]
drupal-7.0.tar.gz: Permission denied

Cannot write to `drupal-7.0.tar.gz' (Permission denied).
eyedea@eyedea-ER912AA-ABA-SR1810NX-NA620:/var/www$ ^C
eyedea@eyedea-ER912AA-ABA-SR1810NX-NA620:/var/www$ wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz
--2012-02-08 21:46:34--  http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz
Resolving ftp.drupal.org... 64.50.236.52, 64.50.233.100
Connecting to ftp.drupal.org|64.50.236.52|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2728271 (2.6M) [application/x-gzip]
drupal-7.0.tar.gz: Permission denied

Cannot write to `drupal-7.0.tar.gz' (Permission denied).

我检查了 /var/www 的权限,但无法更改它们。这里发生了什么?

答案1

这是完全正常的。你的/var/www目录属于用户和具有这些权利的组drwxr-xr-x

/var/www拥有root 权限要好得多,因为它可以防止可能存在的安全缺陷阿帕奇或者php在此服务器上编写和更改源代码。

你可以做什么:

  1. 让你的 wget 具有 root 权限。例如 :

    $ sudo wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz 或者

    $ su -c "wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz"

  2. 从您的 $HOME 下载它并随后解压它

    $ cd ~; wget http://ftp.drupal.org/files/projects/drupal-7.0.tar.gz

  3. 忽略这些安全建议并更改/var/www

    $ sudo chown `id -u`:`id -g` /var/www

编辑:如果你用 a 打破了你的/var/wwwchmod -R 777 /var/www/*并且没有在地狱中燃烧,你可以感谢上帝并在他来找你之前快速执行这些命令:

$ sudo find /var/www -type d -exec chmod 755 {} \;
$ sudo find /var/www -type f -exec chmod 644 {} \;

相关内容