2

I set up a working Drupal 7 installation on somebody else's server and the image generation only worked if all folders leading to the thumbnail folder were given 777 permission.

This must be a an Apache configuration issue - has anybody else come across this?

2 Answers 2

6

You need to go to your drupal installation root folder and type the following

chown -R user:www-data .
find . -type d -exec chmod u=rwx,g=rx,o= {} \;
find . -type f -exec chmod u=rw,g=r,o= {} \;

where www-data type the user under which apache/http process runs

Then go at sites/ directory and type the following

find . -type d -name files -exec chmod ug=rwx,o= '{}' \;
find . -name files -type d -exec find '{}' -type f \; | while read FILE; do chmod ug=rw,o= "$FILE"; done
find . -name files -type d -exec find '{}' -type d \; | while read DIR; do chmod ug=rwx,o= "$DIR"; done

See http://drupal.org/node/244924 for more information.

3
  • Just linking to external (drupal.org) resources is not the best option. We want this stackexchange site to become the one-stop answer database :)
    – berkes
    Commented May 30, 2011 at 20:12
  • The answer is just perfect there and I think more complete than you give. At sites/ directory there are different permissions. I thought it would not be correct just to copy paste a ready answer. And I never imagined drupal.org as a competitor of this site. Anyway here information is more organized.
    – john
    Commented May 30, 2011 at 22:39
  • Please see drupal.stackexchange.com/questions/how-to-answer section "Provide context for links". You neither gave context nor quoted the relevant parts.
    – berkes
    Commented May 31, 2011 at 11:26
3

As provided by John, Drupal.org has an entire page on permissions.

With ls -alh you will see the user and filepermissions that are used. If that gives access denied, or too little information, run ls -alh as root: sudo ls -ahl. You should see something like:

drwxrwx---  7 www-data greg      4096 2008-01-18 11:02 files/
drwxr-x--- 32 greg     www-data  4096 2008-01-18 11:48 modules/
-rw-r-----  1 greg     www-data   873 2007-11-13 15:35 index.php

The first column will, in your situation look like drwxrwxdrwx, a more readable version of 777.

The next two columns are more important: they should contain the user under which the apache server runs. On Ubuntu and Debian that is www-data, under CenOS/Redhat that is apache. Other unices may have other usernames.

Then simply change the ownership of the files directory and all files underneath it.

chown -R www-data:www-data files/ 

This will recursively (-R) change group and user ownership to apache of files/ and its content.

From there you can change the permissions to something safer:

sudo find . -type d -exec chmod u=rwx,g=rx,o= {} \; #change permissions on directories (-d)
sudo find . -type f -exec chmod u=rw,g=r,o= {} \; #change permissions on files (-f)

x for directories means accessing and scanning it. x for files meens executable. You don't want your images to be "executable" :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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