Page 1 of 1

Looking for chmod settings to allow chmod() in PHP

Posted: Tue Nov 10, 2009 3:17 pm
by mrcoffee
Hello. I accidentally ran the command "sudo chmod -r 777 /" on our server, and while I've corrected most of the permissions there are still a few problems here and there.

One problem I'm having is that chmod() now triggers the following error:
Warning: chmod() [function.chmod]: Operation not permitted in [...]
My understanding is that I need to allow php to run this command, but I'm not sure for what files the permissions need to be changed or what they need to be changed to.

Any ideas would be greatly appreciated.

Thank you!

Re: Looking for chmod settings to allow chmod() in PHP

Posted: Wed Nov 11, 2009 2:15 am
by cpetercarter
The permissions on a file can changed only by the owner of the file. If php did not create the files concerned, it is unlikely to own them, and therefore cannot change the permissions. Don't forget that, in most php installations, php runs with a user name such as 'www-data' and not with whatever user-name you personally have on the system. You will have to go back and change the file permissions by hand in the terminal as sudo - sorry. (Comfort yourself with the thought that at least you did not recursively delete all files in the root directory!)