Search My Techie Guy

Monday, May 2, 2016

DRUPAL WEBSITE PERMISSIONS FIX

Summary: 
DRUPAL WEBSITE PERMISSIONS FIX (UNIX/LINUX)

Problem or Goal:
Recommended steps to fix the website file/folder permissions

Cause: 
File Permission issues on drupal

Solution: 

# 1. Create a new example user.

useradd -s /bin/bash -m example;

# 2. Now add that user to the Apache group. On Ubuntu/Debian this group is usually
# called www-data, on CentOS it's usually apache.

usermod -a -G www-data example;

# 3. Set up a password for this user.
  
passwd example;

# 4. Now set the group to the Apache group. -R means recursive, and -v means 
# verbose mode.

chgrp -Rv www-data sites/default/files

# 5. Next we'll set up permissions so that the web server can always write to any 
# file that is in this directory. We do this by using 2775 in our chmod command. 
# The 2 means that the group id will be preserved for any new files created in this 
# directory. What that means is that www--data will always be the group on any files, 
# thereby ensuring that web server and the user will both always have write 
# permissions to any new files that are placed in this directory. 

chmod 2775 sites/default/files

# 6. If there are any existing files in this directory, be sure the web server has 
# write perms on them.

chmod g+w -R sites/default/files

# 7. Ensure that all users only have read permissions.

chmod 444 sites/default/settings.php

# ------------------------------------------------------

Problem Solved?

Yes, Comment if there are any questions.

No comments: