Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I allow php to create files with the same ownership as the files that created them?

PHP creates files with apache:apache ownership which seems to be causing issues with other php scripts accessing the file.

How can I allow php to create files with the same ownership as the files that created them?

I've read elsewhere that having safe_mode turned on can affect this but I've turned it off and reuploaded the files and i still get the same issue.

I'm sure this will be a simple question for someone more familiar with apache but I've failed to find the solution by searching around.

Thanks

like image 220
DonutReply Avatar asked Sep 03 '10 12:09

DonutReply


1 Answers

If ownership matters and multiple users / projects are on the same server, you might want to look into SuExec in Apache: PHP files will then be run by the user indicated in the settings, so default ownership of files is automatically taken care of. It saves a lot of chown/chmod'ing, and the processes run by the user are more easily restricted.

Otherwise, I normally create a group with both the owner & apache, and set the default umask to 007.

like image 82
Wrikken Avatar answered Oct 27 '22 17:10

Wrikken