我被困在試圖用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()或類似的函數之前設置文件的完整路徑。 –