我有一个简单的脚本,在浏览器中输出Permission denied
警告:
rename('/opt/web/test.tmp', '/opt/web/test.tmp1')
脚本路径为/opt/web/test_rename.php
/opt/
,/opt/web/
和/opt/web/test_rename.php
为777,拥有apache
所有者/群组。
httpd
流程所有者为apache
test.tmp
是777,拥有apache
所有者
它适用于cli。
我还能做些什么来让它通过apache工作?
答案 0 :(得分:0)
问题在于SELinux。它可以阻止php rename
函数。
我在这里找到了答案:http://forums.fedoraforum.org/archive/index.php/t-111081.html
在Fedora Core 3 Linux发行版上,您可能会收到“未能打开的流:允许拒绝...”消息。实际上,更改目录的权限将不起作用(即使您设置为0777)。
这是因为新的SELinux内核允许apache用户只在/ tmp目录中编写(我认为)。为了解决这个问题,您必须禁用SELinux(至少对于apache服务)以允许服务器在其他目录中写入。为此,请运行system-config-securitylevel
应用并禁用SE to apache服务。重新启动系统并继续工作。