Drupal File Permissions for non-shared hosting

All directories in root should be set to 750 with setgid set, to do so cd into it and run

sudo find  . -type d -exec chmod 2750 {} \ ;

All files in root should be set to 640 , to do so run 

sudo find . -type f -exec chmod 640 {} \ ;

Now remove the setgid bit on sites/default and all its sub folders by running

sudo chmod -R g-s  sites/default

And change permissions on sites/default/files to 770 for directories and 660 for files

sudo chmod sites/default/files 770

sudo find sites/default/files -type d -exec chmod 770 {} \ ;

sudo find sites/default/files -type f -exec chmod 660 {} \ ;

And very important, change settings.php file to read only 

sudo chmod sites/default/settings.php 400

Note on some shared hosting you will need more permissive permissions

 

Tags: