Apache+PHP write permissions on unix Apache+PHP write permissions on unix apache apache

Apache+PHP write permissions on unix


Warning: file_put_contents(/var/www/public/temp.txt) [function.file-put-contents]: failed to open stream: Permission denied in /var/www/public/newtest.php on line 8

There is so much bad stuff here.

Lets start with the fact that you really want to keep httpd writeable files well away from your code - certainly in a seperate directory, preferably outside the document root altogether.

chown -R apache:apache www and set 777 permissions to the folders

And did you check afterwards what the permissions actually were? BTW see also the point above - if you've made your entire website writeable by the everybody then you're just asking for trouble. You certainly chouldn't change BOTH the owner AND the permissions.

Have you got SELinux enabled? (run sestatus as root). If so then you either need to disable it or learn how to configure it - but I'd recommend you get to grips with old-fashioned permissions first, then disable SELinux.

C.


make chmod 775 to newtest.php ;)


ls -la /var/www/public

Just to check :-)