简体   繁体   English

Drupal 7文件系统错误:目录sites / default / files存在但不可写,无法写入

[英]Drupal 7 file system error: The directory sites/default/files exists but is not writable and could not be made writable

I'm copying a Drupal 7 installation from one machine to another. 我正在将Drupal 7安装从一台机器复制到另一台机器。 Both machines are Mac OSX running current versions of MAMP. 两台机器都是Mac OSX,运行当前版本的MAMP。 Procedure as follows: 程序如下:

  1. create sql dump file 创建sql转储文件
  2. rsync -ar path/to/source path/to/destination
  3. chmod -R 755 destination/sites/default/files
  4. chown -R username destination
  5. import sql dumpfile import sql dumpfile
  6. adjust settings.php (actually, they remain the same across environments, but just checking db connect info and $base_url.) adjust settings.php(实际上,它们在不同的环境中保持不变,但只是检查数据库连接信息和$ base_url。)

Everything works here, on the destination side, except that the sites/default/files directory can not be made writable[sic]. 除了site / default / files目录不能写入[sic]之外,目的地一切都在这里工作。 Something in the directory tree and/or permissions is changing, but I can't figure out what/how. 目录树中的某些内容和/或权限正在发生变化,但我无法弄清楚是什么/如何。 What gives? 是什么赋予了?

sites/default/files needs to be writable by the web user, or writable by all users. sites / default / files需要由Web用户写入,或者由所有用户写入。

all users: 全部用户:

chmod -R a+w destination/sites/default/files chmod -R a + w destination / sites / default / files

or, make apache (or whoever your web user is) the owner 或者,使apache(或您的Web用户是谁)成为所有者

chown -R apache:apache destination/sites/default/files chown -R apache:apache destination / sites / default / files

Note: 755 and 777 sets everything as executable. 注意:755和777将所有内容设置为可执行文件。 777 would have worked, it's just not proper. 777会起作用,这是不恰当的。 Executable permission is necessary for directories, but files generally should not be executable unless they need to be. 目录需要可执行权限,但除非需要,否则文件通常不应该是可执行的。

I personally prefer making apache the owner of the files directory and all the contents inside because that's what happens anyway when Drupal writes files. 我个人更喜欢让apache成为files目录的所有者和里面的所有内容,因为无论如何当Drupal写文件时会发生这种情况。

可能你需要在目录上运行restorecon,例如:

restorecon -rv default/

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

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