File system is not writable

2019-01-29 03:05发布

问题:

I installed Drupal 7 in a web host successfully. After installing a module, I got an error errors and and status report gave me this error message:

File system Not writable
The directory /Applications/MAMP/tmp/php does not exist.
You may need to set the correct directory at the file system settings page or
change the current directory's permissions so that it is writable.

I check the permissions for (sites/default/files) and it has 755 permissions and I change it to 777 but nothing happened so I return it back.

I have the following setting for (Home » Administration » Configuration » Media):

Public file system path
sites/default/files

Temporary directory
/Applications/MAMP/tmp/php

and here is the error I am getting:

Warning: file_put_contents(temporary://fileDyFbDg) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://fileeTFMpl) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://fileuB8Tdu) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://filea1KYXG) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.

Please advice.

回答1:

I check the permissions for (sites/default/files) and it has 755 permissions and I change it to 777 but nothing happened so I return it back.

do the same for /Applications/MAMP/tmp/php



回答2:

This reply is for non-windows sites :
In my case, the sites/default/files/ folder was set to 775 ( not a good idea to have it set to 777 )
I had to delete the following folder :

rm -rf /tmp/devel_themer/

Then it worked !



回答3:

The error happens, because your temporary directory is not writable by your web server user.

You may check that in admin panel by going to Reports and Status report at: /admin/reports/status.

To fix it, you've to got to File system in Configuration (at /admin/config/media/file-system), then change your temporary directory to point to your writable directory. If that's correct, then make you set the right permission on it, e.g.

sudo chmod -R 777 /Applications/MAMP/tmp/php

and the same for default files folder:

sudo chmod -R 777 sites/default/files

Drush

If you're using drush, check which folder is set currently by:

drush vget file_temporary_path

Then to fix it, try:

drush vset file_temporary_path /tmp

Here are default temporary directories:

  • OS X: /private/tmp, for MAMP: /Applications/MAMP/tmp/php
  • Linux/Unix: /tmp