I've seen this question raised a few times, including in the PHP.net documentation section, but have not seen a response yet.
I need for PHP to handle file uploads, which I have working just fine. I need PHP to be able to write those uploaded files to someplace other than '/tmp', and that's where my problem comes in.
My server is a Linux server, running Apache and the latest PHP. PHP is installed as an Apache module.
Apache runs as user 'httpd'. For PHP to move an uploaded file, I currently have to write to a directory that is owned by 'httpd' or has group write permissions for the 'httpd' group.
This presents a slight security problem if two or more users host PHP enabled sites on a shared server. First of all, I would end up having to respond manually to requests for a directory to be chgrp'd to 'httpd'. Second, any one user's PHP code could write to any other user's 'httpd' grouped directory.
I'm not in a position to give everyone their own server to serve sites, so I'm looking for an alternate solution, and starting to believe there is not a good one.
I'm under the impression that enabling suEXEC in Apache would solve the problem, but I'm paranoid about the potential risks involved in doing so. I'm also not too excited about the prospect of running PHP as a CGI binary, especially since I'll likely have to keep the Apache module running at the same time.