2016-03-06 51 views
0

我在本地主機上更新到PHP 7,但自那時以來,我想在我的nette應用程序中從一個頁面重定向到另一個頁面,我將收到錯誤:500 - 內部服務器錯誤我的PHP應用程序死於fastcgi:意外的文件結尾

我正在通過堆棧溢出進行搜索,發現這裏的問題與我的非常相似:How to solve "mod_fastcgi.c.2566 unexpected end-of-file (perhaps the fastcgi process died)" when calling .php that takes long time to execute?。但是,我不使用大文件,並且我的連接立即死亡。

/var/log/lighttpd/error.log

2016-03-06 10:54:11: (server.c.1456) [note] graceful shutdown started 
2016-03-06 10:54:11: (server.c.1572) server stopped by UID = 0 PID = 351 
2016-03-06 11:03:48: (log.c.194) server started 
2016-03-06 11:07:17: (mod_fastcgi.c.2390) unexpected end-of-file (perhaps the fastcgi process died): pid: 21725 socket: unix:/run/lighttpd/php-fastcgi.sock-3 
2016-03-06 11:07:17: (mod_fastcgi.c.3171) response not received, request sent: 1029 on socket: unix:/run/lighttpd/php-fastcgi.sock-3 for /~rost/lp/web/www/index.php?, closing connection 
2016-03-06 11:09:01: (mod_fastcgi.c.2390) unexpected end-of-file (perhaps the fastcgi process died): pid: 21725 socket: unix:/run/lighttpd/php-fastcgi.sock-3 
2016-03-06 11:09:01: (mod_fastcgi.c.3171) response not received, request sent: 1061 on socket: unix:/run/lighttpd/php-fastcgi.sock-3 for /~rost/lp/web/www/index.php?action=list&presenter=Campaign, closing connection 
2016-03-06 11:09:06: (mod_fastcgi.c.2390) unexpected end-of-file (perhaps the fastcgi process died): pid: 21725 socket: unix:/run/lighttpd/php-fastcgi.sock-3 
2016-03-06 11:09:06: (mod_fastcgi.c.3171) response not received, request sent: 942 on socket: unix:/run/lighttpd/php-fastcgi.sock-3 for /~rost/lp/web/www/index.php?, closing connection 
2016-03-06 11:09:14: (mod_fastcgi.c.2390) unexpected end-of-file (perhaps the fastcgi process died): pid: 21725 socket: unix:/run/lighttpd/php-fastcgi.sock-3 
2016-03-06 11:09:14: (mod_fastcgi.c.3171) response not received, request sent: 1051 on socket: unix:/run/lighttpd/php-fastcgi.sock-3 for /~rost/lp/web/www/index.php?action=out&presenter=Sign, closing connection 

/etc/lighttpd/lighttpd.conf

server.modules  = ("mod_userdir", 
         "mod_access", 
         "mod_accesslog", 
         "mod_fastcgi", 
         "mod_rewrite", 
         "mod_auth" 
         ) 
server.port   = 80 
server.username  = "http" 
server.groupname  = "http" 
server.document-root = "/srv/http" 
server.errorlog  = "/var/log/lighttpd/error.log" 
dir-listing.activate = "enable" 
index-file.names  = ("index.html") 

# Rewrite URL without dots to index.php 
#url.rewrite-once  = ("/^[^.?]*$/" => "/index.php") 
mimetype.assign  = (".html" => "text/html", 
         ".htm" => "text/html", 
         ".txt" => "text/plain", 
         ".properties" => "text/plain", 
         ".jpg" => "image/jpeg", 
         ".png" => "image/png", 
         ".svg" => "image/svg+xml", 
         ".gif" => "image/gif", 
         ".css" => "text/css", 
         ".js" => "application/x-javascript", 
         "" => "application/octet-stream" 
         ) 
userdir.path   = "public_html" 

# Fast CGI 
include "conf.d/fastcgi.conf" 

的/ etc/lighttpd的/ conf目錄.d/fastcgi.conf

server.modules += ("mod_fastcgi") 

#server.indexfiles += ("index.php") #this is deprecated 
index-file.names += ("index.php") 

fastcgi.server = (
    ".php" => (
     "localhost" => ( 
     "bin-path" => "/usr/bin/php-cgi", 
     "socket" => "/run/lighttpd/php-fastcgi.sock", 
     "max-procs" => 4, # default value 
     "bin-environment" => (
      "PHP_FCGI_CHILDREN" => "1", # default value 
     ), 
     "broken-scriptfilename" => "enable" 
    )) 
) 

變量/etc/php/php.ini

cat /etc/php/php.ini | grep max_execution_time 
max_execution_time = 30 

cat /etc/php/php.ini | grep default_socket_timeout 
default_socket_timeout = 60 

更新2016年3月7日

我從PHP快速CGI切換到PHP-FPM和有趣的事情是,問題普遍存在,但不太經常。有時重定向跳轉到500,有時不。並再次錯誤日誌:

2016-03-07 22:23:32: (mod_fastcgi.c.2390) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: unix:/run/php-fpm/php-fpm.sock 
2016-03-07 22:23:32: (mod_fastcgi.c.3171) response not received, request sent: 1084 on socket: unix:/run/php-fpm/php-fpm.sock for /~rost/lp/web/www/index.php?action=out&presenter=Sign, closing connection 

回答

0

我終於找到了解決方案。這可能是Nette/Cassandra相關的問題。

錯誤是出現因爲物體•奈特\安全\身份,我分配的用戶數據導入之後:

public function authenticate(array $credentials) { 

    // Retrieve username and password 
    list($email, $passwd) = $credentials; 

    // Select user with given email from database 
    $usr = $this->daoManager->getDao("AppUser")->loadByEmail($email); 
    if ($usr == null || count($usr) == 0) { 
    $msg = 'The email is incorrect.'; 
    $arg = self::IDENTITY_NOT_FOUND; 
    throw new Nette\Security\AuthenticationException($msg, $arg); 
    } 

    // TODO Check user password 
    // TODO Check verification  

    // Create identity - THE PROBLEM WAS HERE 
    return new Identity($email, $usr['role'], $usr); 
} 

它是由在$ USR陣列「註冊」值,它是類型卡桑德拉\所致時間戳。從那時起,幾乎所有的重定向都與上面提到的錯誤一起墜毀。

下面的代碼解決了該問題:

return new Identity($email, $usr['role'], $this->fixUserArray($usr)); 

其中:

protected function fixUserArray(array $user) { 
    $result = array(); 
    foreach ($user as $key => $val) { 
    if ($key === "registered") { 
     $result[$key] = $val->time(); 
    } else { 
     $result[$key] = $val; 
    } 
    } 
    return $result; 
} 
0

此外,嘗試先刪除Nette緩存。

+0

•奈特緩存刪除不會幫助:( – Michal