如题,我当前的网站目录是/var/www/html(777权限)
然后我的
/var/www/html/g/data/visit.php 文件
require(../function.php);if (file_exists($_server[document_root]. /cache/vc-$date.json)) { echo file_get_contents($_server[document_root]. /cache/vc-$date.json);} else { $res=get_sum(); $days1=get_days(1); $month=get_this_month(); $result=[visit=>$res,'days'=>$days1,'month'=>$month]; $echo = json_encode($result); cache_this($echo,'vc-'.$date); echo $echo;}
function.php
function cache_this($result,$name){//内容,命名规则 //file_put_contents(/cache/$name.json, $result)or die(unable to open file!); $myfile = fopen($_server['document_root']./cache/$name.json, w) or die(unable to open file!); $txt = $result; fwrite($myfile, $txt); fclose($myfile);}
这是我ls -l的部分结果
-rwxrwxrwx. 1 root root 81 11月 4 2013 bottom.phpdrwxrwxrwx. 2 apache apache 4096 11月 10 17:09 cache
然后我看了httpd.conf里面的user和group,都是apache没有错
但是这个json文件就是写不进cache文件夹里面,$myfile总是返回false。
求教这个是什么问题,已经折腾了一晚上,双十一centos讨论群里面都在水,也没问出个究竟……
急求…………………………(无力
回复内容: 如题,我当前的网站目录是/var/www/html(777权限)
然后我的
/var/www/html/g/data/visit.php 文件
require(../function.php);if (file_exists($_server[document_root]. /cache/vc-$date.json)) { echo file_get_contents($_server[document_root]. /cache/vc-$date.json);} else { $res=get_sum(); $days1=get_days(1); $month=get_this_month(); $result=[visit=>$res,'days'=>$days1,'month'=>$month]; $echo = json_encode($result); cache_this($echo,'vc-'.$date); echo $echo;}
function.php
function cache_this($result,$name){//内容,命名规则 //file_put_contents(/cache/$name.json, $result)or die(unable to open file!); $myfile = fopen($_server['document_root']./cache/$name.json, w) or die(unable to open file!); $txt = $result; fwrite($myfile, $txt); fclose($myfile);}
这是我ls -l的部分结果
-rwxrwxrwx. 1 root root 81 11月 4 2013 bottom.phpdrwxrwxrwx. 2 apache apache 4096 11月 10 17:09 cache
然后我看了httpd.conf里面的user和group,都是apache没有错
但是这个json文件就是写不进cache文件夹里面,$myfile总是返回false。
求教这个是什么问题,已经折腾了一晚上,双十一centos讨论群里面都在水,也没问出个究竟……
急求…………………………(无力
查看selinux状态
为啥非要写到根目录 当前目录不行么