我被困在试图用php打开一个文件与fopen。PHP无法读取文件
$db_ausgaenge = "statuseing.php";
$dout = fopen($db_ausgaenge, "x+");
print $dout;
print(shell_exec('whoami'));
print(shell_exec('pwd'));
print(shell_exec('id'));
fwrite($dout, $out);
fclose($dout);
Warning: fopen(statuseing.php): failed to open stream: File exists in /var/www/html/zufallsgenerator.php on line 33
我检查以下项目:
- CHMOD为statuseing.php 0777
- 所有者是www数据与对地表www数据
- 脚本运行作为用户WWW的数据
- groups is uid = 33(www-data)gid = 33(www-data)groups = 33(www-data)
- pwd是/ var/www/html
- 脚本想要打开的路径是正确的
在php.ini中检查openbase dir显示在phpinfo()中,添加了/ var/www/html,但php并不关心它。
的open_basedir =在/ var/www/html等/
通过systemctl什么守护重载和重新启动的Apache2改变后,phpinfo()函数没有显示在配置中给出的路径。通过init 6重新启动系统也没有生效。
换开的方法来 'W +',现在它的正常工作。感谢提到这个问题。 –
虽然这不是你的问题,但我个人总是喜欢在调用fopen()或类似的函数之前设置文件的完整路径。 –