在UNIX上的Apache + PHP写权限 [英] Apache+PHP write permissions on unix

查看:118
本文介绍了在UNIX上的Apache + PHP写权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图推出PHP站点在Fedora Apache和我有一个关于书面方式权限问题。它看起来像阿帕奇没有写权限对某些文件夹,但我canno明白为什么。

我检查了httpd.conf中,它有组:阿帕奇,用户:阿帕奇。
然后我:
CHOWN R的阿帕奇:阿帕奇WWW和设置777权限的文件夹,但它仍然说:


  

警告:的file_put_contents(/var/www/public/temp.txt)function.file-把-内容]:未能打开流:权限在/var/www/public/newtest.php否认8号线


请咨询。

更新:
顺便说一句,如果我做PHP newtest.php命令行,文件TEMP.TXT与组根和根用户创建的。它只是利己无法从浏览器。


解决方案

  

警告:的file_put_contents(/var/www/public/temp.txt)function.file-把-内容]:未能打开流:权限在/var/www/public/newtest.php否认8号线


有这么多坏的东西在这里。

让我们开始的事实,你真的想保留httpd的可写文件从code得好远 - pferably肯定是在一个单独的目录,$ P $文档根目录以外的共有


  

CHOWN R的阿帕奇:阿帕奇WWW和设置777权限的文件夹


和你检查以后的权限,实际上是? BTW也看到了点以上 - 如果你已经被大家让你的整个网站可写入,那么你只是在自找麻烦。你当然chouldn't更改所有者和权限。

你有将SELinux? (运行sestatus根)。如果是这样,那么你需要禁用它,或者学习如何配置它 - 但我建议你与老式的权限交手,然后再禁用SELinux

℃。

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.

这篇关于在UNIX上的Apache + PHP写权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆