2013-01-07 18 views
9

Tôi đang phải đối mặt với các lỗi sau:của router 'Zend_Log_Exception' với file.log nhắn không thể mở được với chế độ "a"

Uncaught exception 'Zend_Log_Exception' with message file.log cannot be opened with mode "a"

Trong bootstrap của tôi, tôi có đoạn mã sau:

$logfile = PROJECT_PATH . DIRECTORY_SEPARATOR .'/tmp/logs/'.$config->app->logfile.'.log'; 

if (!file_exists($logfile)) 
{ 
    $fp = fopen($logfile, 'a'); 
    fclose($fp); 
} 

$redacteur = new Zend_Log_Writer_Stream($logfile); 
$logger = new Zend_Log($redacteur); 

đầy đủ các trang báo lỗi:

Warning: fopen(/home/http/me.tv/fbapps/www//tmp/logs/vengeance.log) [function.fopen]: failed to open stream: No such file or directory in /home/http/me.tv/fbapps/www/inline/bootstrap_vengeance.php on line 81

Warning: fclose() expects parameter 1 to be resource, boolean given in /home/http/me.tv/fbapps/www/inline/bootstrap_vengeance.php on line 82

Fatal error: Uncaught exception 'Zend_Log_Exception' with message '"/home/http/me.tv/fbapps/www//tmp/logs/vengeance.log" cannot be opened with mode "a"' in /home/http/me.tv/fbapps/www/library/Zend/Log/Writer/Stream.php:78 Stack trace: #0 /home/http/me.tv/fbapps/www/inline/bootstrap_vengeance.php(85): Zend_Log_Writer_Stream->__construct('/home/http/medi...') #1 /home/http/me.tv/fbapps/www/htdocs/vengeance/index.php(9): require_once('/home/http/medi...') #2 {main} thrown in /home/http/me.tv/fbapps/www/library/Zend/Log/Writer/Stream.php on line 78

Trả lời

17

Đặt phép phải vào file: 0777.

Kiểm tra xem thư mục /home/http/me.tv/fbapps/www/tmp/logs/ tồn tại, sau đó chạy lệnh này trong một thiết bị đầu cuối: dùng máy chủ

chmod 777 /home/http/me.tv/fbapps/www/tmp/logs/vengeance.log 
+0

thx để được trợ giúp – Slrg

+2

Tôi có quyền '755' trên toàn bộ thư mục và tệp không tồn tại. Thay đổi quyền trên thư mục thành '777' đã giải quyết được vấn đề. – Radek

+1

Tôi đã đặt chmod 777 trên cả tệp và thư mục .. PHPUnit là sitll cho tôi cùng một thông báo lỗi. 'không thể mở ở chế độ" a "' – Erik

0

Web nên có quyền viết và exec (đi qua) vào thư mục bản ghi.

chown www-data:www-data -R logs/ # change www-data by the user of the web server chmod 755 -R logs/

Đó là một ý tưởng rất xấu để đặt 777 ở đâu đó.

Các vấn đề liên quan