I am pretty new to unix & drupal, but I do understand the basics of permissions and groups.
However, I had to create the /files and files/tmp folder manually via FTP, since Drupal 5 didn't create it.

Drupal complained /files wasn't writable until I gave it permissions 777. Both folders are owned by me, since I created it under FTP.

/var/www/vhosts/mywebsite.com/httpdocs
drwxrwxrwx 8 myusername psacln 4096 Mar 18 20:39 files

/var/www/vhosts/mywebsite.com/httpdocs/files/images
my images folder has the same issue:
drwxrwxrwx 3 myusername psacln 4096 Mar 21 11:15 images

Shouldn't Apache own these folders instead of me?

If so, what is the correct command & what SHOULD these permissions be set to to change this ( i do have root access if needed)? I looked through the handbooks, but couldn't find the definitive answer, and when I did find something, it was usually followed up with a comment saying the info is dated.

Any guidance from someone who really knows would be a blessing!

Comments

preferred name’s picture

without root, 755 for files and images.
next, copy a basic .htaccess into the file dir with the following content.

an example...

IndexIgnore *
Order Allow,Deny
Allow from all
Deny from env=blockAccess

<Files .htaccess>
order allow,deny
deny from all
</Files>

dont worry about owner because you do not have root or you may not be on unix. the server should take care of this for you because the server generally bypasses owner permission and sets it own defaults. Therefore, do not be concern, it is only a pubic dir
chmod .htaccess to 444

onestep’s picture

thanks, I will give that a try!

onestep’s picture

That didn't seem to work for me.

I logged in as root on my Unix VPS and made the changes.

In the directory files , I edited the existing .htaccess file and it now contains this:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

IndexIgnore *
Order Allow,Deny
Allow from all
Deny from env=blockAccess

<files .htaccess>
order allow,deny
deny from all
</files>

I did a chmod on the /files directory to 755
I did a chmod on the /images directory to 755
I did a chmod on the .htaccess file in /files to 444

this is what I have now:

/var/www/vhosts/example.com/httpdocs/files
drwxr-xr-x  2 myusername  psacln  4096 Mar 17 21:06 pictures

/var/www/vhosts/example.com/httpdocs/files
drwxr-xr-x  3 myusername  psacln  4096 Mar 21 13:47 images

After I logged back into the drupal directory, it now says:
The directory files is not writable

Any ideas on how to fix it? Thanks in advance!

preferred name’s picture

Consider that you have deleted the files directory (dir) as you are now starting at the beginning.

login to your site then goto admin/settings/file-system
File system path: files (not /files)
Temporary directory: temp
Download method: public
click the 'save configuration'
select a theme color at admin/build/themes/settings/garland
click the 'save configuration'

When you clicked the 'save configuration' at the themes, drupal created at the root of the files dir, dirs inside of the files dir and files within those dirs.

However, these is an issue with the drupal's automatically created .htaccess file that is now found inside of the files dir. The issue is that a user cannot save another garland theme color without generating an error. Therefore, replace the default .htaccess with the .htaccess that I have given.

Now before you apply the instructions that I have given from my previous comment, ask the following questions.
#1: are you only using the files directory to upload a image that you can link that image within the body of a node too and are you also using it for the garland color changer?
#2: are you providing a service so that users can upload files too and also #1?

If the answer is #1: then with some operating systems and/or how the apache server is configured, the 755 will work while with other hardcode configurations it will not. In that case, just apply to #1 the chmod 777.
If the answer is #2 then chmod to 777

onestep’s picture

Thanks for the follow up. However, before I got this message, I did some more playing around with it and made it work.

In case others have the same issue (and it seems to be fairly common), here is what I did.

I believe it requires root access privileges, and that is what I used to make the modifications.

On the files directory, I made apache the user and group owner.

to do so, I did:

chown -R apache.apache files

I did a -R to make sure it was recursive, and changed the ownership of the tmp folder and a couple others that I had inside.
I also set the permissions to 755

This appears to work perfectly with the multiple users I have configured in drupal. We can now upload images, etc. from within drupal, and it seems to work fine.
This would cause a problem if I was trying to FTP into the folders, under my less privileged username, since apache owns them, and I don't.... but as long as I add images and files with tools inside of the drupal interface, everything works perfectly.