【发布时间】:2011-08-24 19:15:26
【问题描述】:
我最近转移了服务器,并且似乎 file_put_contents 在新服务器上不起作用。
一切都一样,文件夹已正确修改,但由于某种原因,它没有创建文件并将内容放入其中。
我创建了一个测试供您查看,模拟我们目前的做法:
file_put_contents("/home/user/public_html/test/test.progress", "test");
脚本正在运行
/home/user/public_html/test.php
/test folder is chmodded to 755 (777 makes no difference)
我收到以下错误:
Warning: file_put_contents(/home/user/public_html/test/test.progress) [function.file-put-contents]: failed to open stream: Permission denied in /home/user/public_html/test.php on line 2
我是否需要更改服务器上的任何设置才能使其正常工作?怎么了?
【问题讨论】:
-
需要更多关于环境的信息。
-
服务器运行的用户可能与文件夹 /test 的创建者不同
-
Cent OS,linux,服务器版本:Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.3.6
-
试试
file_put_contents($file, $content, FILE_APPEND | LOCK_EX);