Drupal 7 module update failed:
I was encountering the following warning when trying to perform an upgrade of Drupal 7 google_analytics module to the latest version.
•Error installing / updating
•File Transfer failed, reason: Cannot create directory /public_html/sites/all/modules/google_analytics
My immediately highly secure approach was to make the www-data user and group the owner, make the default directory and the PHP config files in it readable only by www-data, and make the files subdirectory readable and writeable only by www-data.
chown -R www-data:www-data /public_html/sites/default
chmod u=rx,g=rx,o= /public_html/sites/default
chmod u=rwx,g=rwx,o= /public_html/sites/default/files
chmod u=r,g=r,o= /public_html/sites/default/*.php
However, the outcome of above action was that the error still persisted. My second approach in resolving the above-mentioned error was to do the following and still maintaining the high level security the directory:
chown -R www-data:www-data /public_html/sites/all/modules/
After running this command, all worked beautifully well. I’m of a view this will resolve any Drupal 7 update related issues.