PHP mkdir and apache ownership

Bill H picture Bill H · Apr 1, 2010 · Viewed 18.4k times · Source

Is there a way to set php running under apache to create folders with the folder owned by the owner of the program that creates it instead of being owned by apache?

Using word press it creates new folders to upload into but these are owned by apache.apache and not by the site that they are running in. This also happens using ostickets. For now we have to SSH into the server and chmod the folder, but it would seem there would be a setting somewhere to override the ownership outside of any program that does it.

Answer

Sanhe picture Sanhe · Apr 7, 2010

Safe_mode is turn on on your server. The function mkdir() creates folder with owner ("apache", "none", ..) that different of the current script owner. And scripts couldn't upload (move, copy) files into that folder with another owner (that is not like current script owner).

Disable safe_mode and that would be work.

See http://php.net/manual/en/features.safe-mode.php for details.

P.S. With enable safe_mode you can't use chmod() function in php.