2010-01-13 45 views
5

我試圖初始化會話,但我得到這個錯誤:PHP允許對話問題

Warning: session_start() [function.session-start]: open(/tmp/sess_7af3ee9ec1350680bedcf63833d160bd, O_RDWR) failed: Permission denied (13)

的session.path設置到/ tmp 777個燙髮。

我嘗試將session.path編輯爲「0; 777;/tmp」,但會話文件是使用錯誤的權限(僅寫入)創建的。

我在apache2和ubuntu 9.10上使用PHP 5.2。 任何想法?

回答

4

請確認/ tmp目錄的權限,真的是xx777

<?php 
error_reporting(E_ALL); 
ini_set('display_errors', 1); 
$s = stat('/tmp'); 
printf('%o', $s[2]); 
file_put_contents('/tmp/phptest1234.txt', 'test'); 
unlink('/tmp/phptest1234.txt'); 

編輯:下一次嘗試,umask

<?php 
echo ' php-umask: ', sprintf('%o', umask()), "\n"; 
echo ' exec-umask: ', exec('umask'), "\n"; 
+0

您的腳本返回44777. 會話文件寫入/ tmp,但具有錯誤權限:php創建具有100366權限的會話文件。我可以寫但不能讀。 – Daniel 2010-01-14 08:53:46

+0

這聽起來像0411的umask,請參閱編輯。 – VolkerK 2010-01-14 12:11:20

+0

返回: php-umask:22 exec-umask:0022 – Daniel 2010-01-14 16:38:21

1

好像你沒有寫入tmp目錄的權限,你需要給它權限來保存文件。

+0

+1:上週讓我想起了當我運行某個其他人設置的計算機的/ tmp爲0770而不是1777或1666的計算機時出現的情況。來想一想,這也是Ubuntu服務器。 – Powerlord 2010-01-13 18:03:45

+1

看起來他已經說過/ tmp的perms設置爲777. – 2010-01-13 18:07:46

0

我解決這個問題,有一個第三方庫,設置錯誤的umask到777,刪除它的問題就解決了。感謝您的回答。

+2

我有同樣的問題。我該如何解決它? 。謝謝 – bader 2010-03-15 15:34:52

1

我也有這個問題。有在/ etc/SYSCONFIG/httpd的這是不正確地設置umask的一條線,所以我評論一下:

#umask 644 

一切都很好了。