title: Secure way to allow a specific PHP script to read/write a directory?
body: <p>I have a php script that needs to create/delete files within the /www/mydata directory (using centos+linux+apache).</p>
  
  <p>I gave the "apache" user ownership of www/mydata to allow this.</p>
  
  <p>Is that secure enough?  Is there a better method?  I would much prefer that ONLY the specific script have "ownership" of www/mydata and only while it's running, in case someone is getting up to shenanigans.</p>
  
  <p>Can that be done, or am I stuck giving the apache user all these privs?</p>
  
  <p>Edit: to forestall a few obvious answers, I have attempted to have the script create the directory (it can't) and I've also attempted to set the directory permissions in the script on the fly using PHP's chmod (no deal).</p>