开发者

Apache+PHP write permissions on unix

I'm trying to launch PHP site with apache on fedora and I have a problem about writting permissions. It looks like apache does not have write permissions to some folders, but I canno understand why.

I've checked httpd.conf and it has group: apache, user: apache. I then made: chown -R apache:apache www and set 777 permissions to the folders, but it still says:

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

Please advice.

UPDATE: Btw, if I make "php开发者_运维百科 newtest.php" from command line, the file temp.txt is created with group root and user root. It just doest not work from the browser.


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 :-)


I'd recommend switching apache to mod_itk as mpm and running the particular vhost with permissions of the owner document root directory and contained php scripts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜