0

I have a clean install of Drupal 8 on a new Centos 7 server. This is the first module I have attempted to install. I'm using the built in update manager. I get the following error.

File Transfer failed, reason: Cannot create directory /var/www/html/modules/somemodule

This seems like a common enough permissions problem but no answers I've found on similar questions have worked. The webserver user is apache (not www-data) and it owns the modules directory. I have confirmed this with ps aux | grep -i 'www\|apache\|nginx'.

These are the current permissions.

drwxr-xr-x.  2 apache apache    24 Jan  3 13:27 modules

I have chowned and chmodded until I'm blue in face, but it hasn't changed anything since the apache user already owns the directory and should be able to write it.

/admin/reports/status shows all green including FILE SYSTEM Writable (public download method).

What could be wrong? How can I further troubleshoot?

I am using PHP 7.1.14, Apache httpd-2.4.6-67.el7.centos.6.x86_64, and Drupal 8.4.4.

Update:

I have tried chmod -R 777 as a test and receive the same error. I have also tried creating the directory for the module manually but the update manager is still unable to copy files to it.

Update 2:

I have downgraded to php 7.1 to be fully compliant with Drupal 8 requirements but this has not solved the issue or changed the behavior.

closed as too broad by Shawn Conn, Scott Joudry, marcvangend, DRUPWAY, kenorb Mar 20 '18 at 10:58

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Drupal 8.4.4 doesn’t support php7.2, you should downgrade to 7.1 or wait for Drupal 8.5. It won’t be the cause of this specific issue but it will probably bite you later on – Clive Feb 16 '18 at 17:40
  • what are your permissions like on the 'files' directory? Probably located here '/var/www/html/sites/default/files' – ec0g Feb 16 '18 at 18:02
  • permissions on files for apache user are drwxrwxr-x – Anonymous Man Feb 16 '18 at 19:35
  • I also tried chmod -R 777 as a test and received the same error. – Anonymous Man Feb 16 '18 at 19:41
  • I'm voting to close this question as off-topic because this question is not about Drupal, but about server administration and Linux systems. – marcvangend Mar 2 '18 at 20:57
0

This turned out to be an SELinux issue. SELinux is enabled and running in enforcing (strictest) mode by default in Centos 7 and this will prevent the web user from being able to write to /modules or /files (or anywhere) regardless of the file permissions set.

To see if you may be having the same problem:

more /etc/selinux/config

This will display the SELinux config file and let you know if it is enabled and what mode it is in.

The issue can be corrected with the following commands:

sudo chcon -Rt httpd_sys_content_t /var/www/html
sudo chcon -Rt httpd_sys_rw_content_t /var/www/html/sites/default/files
sudo chcon -Rt httpd_sys_rw_content_t /var/www/html/modules
sudo chcon -Rt httpd_sys_rw_content_t /var/www/html/vendor

This will correct the context of the directories you want to grant write permissions on so that Drupal will work without disabling SELinux. For more information see the man pages for selinux and chcon.

Not the answer you're looking for? Browse other questions tagged or ask your own question.