當safe_mode設置爲 on,PHP 將通過文件函數或其目錄檢查當前腳本的擁有者是否和將被操作的文件的擁有者相匹配。例如:-rw-rw-r-- 1 rasmus rasmus 33 Jul 1 19:20 script.php
-rw-r--r-- 1 root root 1116 May 26 18:01 /etc/passwd
運行 script.php<?php
readfile('/etc/passwd');
?>
如果安全模式被激活,則將會導致以下錯誤:Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not
allowed to access /etc/passwd owned by uid 0 in /docroot/script.php on line 2
haohappy的說法:
原因在於你使用了安全模式,而你上傳文件的用戶uid和擁有者的uid不同,導致沒有訪問權限。比如安全模式下,你的ftp上傳用戶uid爲123,而上傳後擁有者的uid爲456,就會出現這樣的錯誤。
有兩種解決方法:
1。關閉安全模式;
2。在命令行下chown改文件/目錄的擁有者
當然兩種方法都要求你有服務器的權限。