I'm learning php, and am having a problem while writing a file upload page. In the docroot, I have index.php (the page that calls fopen) and a directory called "images", where I wish the temporary file be moved. However, fopen fails with 'permission denied' ( vide /var/log/httpd/error_log ). fopen is called requesting a write.
I scoured the net and found the problem was with permissions on the images dir. I first changed the group owner of the dir to a group different than root and added 'apache' to that group. group has w permission on the dir. (I found out that my Apache was running as user apache with
# ps aux| grep httpd
This failed.(should have worked, no?)
Again, I chowned the entire images/ dir to be owned by 'apache'. in vain.
And yes, I restarted the server after each of the above changes was made.
thanks,
Yati
PS: My reputation here doesn't allow me to self-answer within 8 hrs, so decided to edit here. With help from Ignacio, the command for changing the SELinux context of the images dir is:
# chcon -R -h -t httpd_sys_rw_content_t ./images
from within the docRoot.
thanks again.