File ownership with chmod and chown

Q I'm having a problem with chmod in two areas. I generally use WS_FTP PRO to upload files, and sometimes have to change the mode after uploading. The first problem I'm running into (and this has never happened before, with 35 sites running), is that a certain file will not change... I get permission denied. I also get that if I try to re-download it back to my computer. The dir it is in is set to 777 and I can set the chmod of another file in that dir. So basically Linux will not let me change the mode on this one file. Any ideas? Also, if I try to CHMOD thru php it tells me:

Warning: chmod failed: Operation not permitted in
/home/httpd/vhosts/etc...etc on line 65

I think this is due to a php.ini setting... Please Help!

A I believe that both problems are related here. It sounds like the file that you are trying to isn't owned by you, and you are not in the group perms of the file. Try examining the ownership of the file you are able to change. That's the owner/group combination that is allowed to change those files. When files are created, you need them to all be owned by the same group, and then make sure that the group has write permissions. For example, if the directory's owner/group permissions (and all subfiles) need to be "root:apache 775", then you need to do a:

chown -R root:apache dirname

and then to set the SGID and sticky bits to enforce this, do a:

chmod 3755 dirname ; chmod -R 755 dirname/*

(if there are more subdirs, thecommand is a bit more complex). This will set up the "dirname" directory with the proper user/group perms for a shared upload environment.

Follow us on or Twitter

Username:   Password: