Hello all,

I'm new to this community, and asking for help because I'm stuck on this problem, and cannot go past. I've also tried asking on StackOverflow on /questions/61414218/, but with no luck so far.

My current setup:

  • Drupal 8.8.5
  • CentOS Linux release 7.5.1804
  • PHP 7.2.19 and HTTPD - Apache/2.4.6
  • Run user/group: apache:apache

The /admin/reports/status#warning admin page reports that "the sites/default/files directory is not writable. You may need to set the correct folder in the configurations of the File system page or change the permissions of the current folder so that it is writable."

Obviously, this leads to a number of errors:

Drupal\Core\File\Exception\FileException: Failed to unlink file 'public://css/css_Y3zRgmC0P7yIXk_w_H9qyrPs3aMkKRv44SMfupbSCMc.css.gz'. in Drupal\Core\File\FileSystem->delete() (line 340 of/var/www/html/project/core/lib/Drupal/Core/File/FileSystem.php).

Warning: unlink(/var/www/html/project/sites/default/files/css/css_Y3zRgmC0P7yIXk_w_H9qyrPs3aMkKRv44SMfupbSCMc.css.gz): Permission denied in Drupal\Core\File\FileSystem->unlink() (line 124 of /var/www/html/synergie/core/lib/Drupal/Core/File/FileSystem.php)

The specified file 'temporary://fileuJjxaE' could not be moved to 'public://js/js_FKKJ_OhNvc7muQ1i_fQS6OJmZLsZnRvVhbbPaVlNwb8.js'.

Permissions for the file cannot be set for sites/default/files/translations

Now, I'm not a full expert on Drupal, but I've already tried doing all the possible basic things that these situations require on a linux system:

  1. Setting all 777 to /var/www/html/project/sites/default and subdirectories
  2. Changing owner of the directory aforementioned
  3. Manually debugging lines 124 and 340 of lib/Drupal/Core/File/FileSystem.php
  4. Sudoing on "apache" user with sudo -s /bin/bash apache and try to create/delete files from the command line (and it works)
  5. Writing custom scripts that run under apache:apache, outside Drupal, to see if they can manipulate public://. (they work)

I think the problem is not in the filesystem itself, because whatever combination of permissions doesn't work, I believe this problem is connected to Drupal itself.

Fact is, if I write a custom script to write/read/move files from/to the /var/www/html/project/sites/default/files, it just works. It doesn't work "from within" Drupal.

As said before, I'm not a expert of all the "under the hoods" of Drupal like file settings, admin settings, drush, so I'm asking to you to try and issue this problem, because it's driving me crazy. Spent the last 10+ hours watching the command line and not understanding what's happening.

Kind regards,

Maurizio

Comments

onejam’s picture

I see this line in your comment: 

The specified file 'temporary://fileuJjxaE' could not be moved to 'public://js/js_FKKJ_OhNvc7muQ1i_fQS6OJmZLsZnRvVhbbPaVlNwb8.js'.

Perhaps, Drupal doesn't know where to locate your /tmp directory? You need to tell drupal where it is in the settings.php file

There is a line to specify the path to your /tmp in settings.php 

$settings['file_temp_path'] = '/tmp';

-----------------------------------------------------------------
We build engaging websites and intuitive designs that will benefit your business.
Duvien

slewazimuth’s picture

The first error posted reports: 

The /admin/reports/status#warning admin page reports that "the sites/default/files directory is not writable

Was your update to 8.8.5 from a Drupal 8 version earlier than 8.8.0? 

ressa’s picture

It looks like Drupal changes permissions for js and css folders after an update, see #3369960-7: type error on drush cr for more.

I am surprised there isn't an issue dedicated to this bug.