Looking for chmod settings to allow chmod() in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrcoffee
Forum Commoner
Posts: 31
Joined: Tue Nov 10, 2009 3:03 pm
Location: Wyoming, USA

Looking for chmod settings to allow chmod() in PHP

Post 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!
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

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

Post 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!)
Post Reply