0
votes

I'm facing very strange behaviour on Drupal 8.8.5, CentOS Linux release 7.5.1804, PHP 7.2.19 and HTTPD - Apache/2.4.6

Basically, after updating to 8.8.5 (that has been a real headache), the system throws errors while flushing css+js files on "flush caches".

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)

This obviously leads to bad frontend and admin panel behaviour.

I've literally tried to do everything I could, by:

  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

What I've found very strange, is that by manually debugging the unlink method on FileSystem.php, it lead to some strange results:

public://css/css_Y3zRgmC0P7yIXk_w_H9qyrPs3aMkKRv44SMfupbSCMc.css.gz: readable and writable

/var/www/html/project/sites/default/files/css/css_Y3zRgmC0P7yIXk_w_H9qyrPs3aMkKRv44SMfupbSCMc.css.gz: readable but not writable

Some notes: - Httpd runs on apache user and apache group

  • I've tried to do every possible combination of folder and write permission and owner and group to every directory and child subdirectories of /var/www/html/project/sites/

  • I've already tried to follow these instructions: Web Archive

  • I've also run this "folder and file permissions script": Drupal Website

Do you have ideas or suggestions? I cannot go past this one

1
If you use sudo or su to change to the apache user, are you able to delete it? I would start checking there. If that works.rovr138
If your files and folders are owned by apache, setting folders to 700 and files to 600 should work (not code. files in your files directory)rovr138
Hi @rovr138, thank you for your hint. I've actually tried to do what you suggested by doing "su -s /bin/bash apache" (because in /etc/passwd the apache user is set to /sbin/nologin). Strange thing: it works. Files are deletable. And the other strange thing is that i can also delete "root" files from the apache user. I don't know what is happening under the hoods, but I've never seen such a thing on a Linux machine :(Maurizio

1 Answers

0
votes

Sounds like SELinux blocking...

Find current mode of SELinux and temporarily shut it down.

Getenforce # see current mode.
Sudo setenforce 0 # shut it down.

Try your thing. If that’s cause, just add rule to allow locations like /var/www/your Docroot