PHP工作正常,但Laravel无法工作,返回503服务不可用

时间:2019-02-21 09:41:56

标签: php laravel apache http-status-code-503

错误日志为:

[Thu Feb 21 13:07:41.791781 2019] [proxy_fcgi:error] [pid 19304] [client 59.547.36.85:57554] AH01071: Got error 'PHP message: PHP Notice:  date_default_timezone_set(): Timezone ID 'Asia/Tehran' is invalid in /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php on line 49
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /public/index.php:0
PHP message: PHP   2. App\\Http\\Kernel->handle() /public/index.php:54
PHP message: PHP   3. App\\Http\\Kernel->sendRequestThroughRouter() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
PHP message: PHP   4. App\\Http\\Kernel->bootstrap() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:146
PHP message: PHP   5. Illuminate\\Foundation\\Application->bootstrapWith() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:162
PHP message: PHP   6. Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap() /vendor/laravel/framework/src/Illuminate/Foundation/Application.php:211
PHP message: PHP   7. date_default_timezone_set() /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:49
PHP message: PHP Warning:  Uncaught ErrorException: DateTime::createFromFormat(): Invalid date.timezone value 'Asia/Tehran', we selected the timezone 'UTC' for now. in /vendor/symfony/http-foundation/ResponseHeaderBag.php:295
Stack trace:
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'DateTime::creat...', '/vendor/symfony...', 295, Array)
#1 /vendor/symfony/http-foundation/ResponseHeaderBag.php(295): DateTime::createFromFormat('U', '1550741861')
#2 /vendor/symfony/http-foundation/ResponseHeaderBag.php(41): Symfony\\Component\\HttpFoundation\\ResponseHeaderBag->initDate()
#3 /vendor/symfony/http-foundation/Response.php(201): Symfony\\Component\\HttpFoundation\\ResponseHeaderBag->__construct(Array)
#4 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Symfony\\Component\\HttpFoundation\\Response->__construct(Object(Illuminate\\View\\View))
#5 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(722): Illuminate\\Routing\\Router::toResponse(Object(Illuminat...
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /public/index.php:0
PHP message: PHP   2. App\\Http\\Kernel->handle() /public/index.php:54
PHP message: PHP   3. App\\Http\\Kernel->sendRequestThroughRouter() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
PHP message: PHP   4. Illuminate\\Routing\\Pipeline->then() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
PHP message: PHP   5. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
PHP message: PHP   6. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP   7. App\\Http\\Middleware\\CheckForMaintenanceMode->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP   8. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
PHP message: PHP   9. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  10. Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  11. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
PHP message: PHP  12. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  13. App\\Http\\Middleware\\TrimStrings->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  14. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
PHP message: PHP  15. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  16. Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  17. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
PHP message: PHP  18. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  19. App\\Http\\Middleware\\TrustProxies->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  20. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/fideloper/proxy/src/TrustProxies.php:57
PHP message: PHP  21. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  22. Barryvdh\\Cors\\HandleCors->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  23. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/barryvdh/laravel-cors/src/HandleCors.php:36
PHP message: PHP  24. App\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
PHP message: PHP  25. Illuminate\\Routing\\Router->dispatch() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
PHP message: PHP  26. Illuminate\\Routing\\Router->dispatchToRoute() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:614
PHP message: PHP  27. Illuminate\\Routing\\Router->runRoute() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:625
PHP message: PHP  28. Illuminate\\Routing\\Router->runRouteWithinStack() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:659
PHP message: PHP  29. Illuminate\\Routing\\Pipeline->then() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:684
PHP message: PHP  30. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
PHP message: PHP  31. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  32. App\\Http\\Middleware\\EncryptCookies->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  33. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
PHP message: PHP  34. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  35. Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  36. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
PHP message: PHP  37. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  38. Illuminate\\Session\\Middleware\\StartSession->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  39. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63
PHP message: PHP  40. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  41. Illuminate\\View\\Middleware\\ShareErrorsF

    [Thu Feb 21 13:07:41.791912 2019] [proxy_fcgi:error] [pid 19304] [client 59.547.36.85:57554] AH01071: Got error 'closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  44. App\\Http\\Middleware\\VerifyCsrfToken->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  45. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:75
PHP message: PHP  46. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  47. Illuminate\\Routing\\Middleware\\SubstituteBindings->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  48. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
PHP message: PHP  49. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  50. Barryvdh\\Cors\\HandleCors->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  51. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/barryvdh/laravel-cors/src/HandleCors.php:36
PHP message: PHP  52. Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
PHP message: PHP  53. Illuminate\\Routing\\Router->prepareResponse() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:682
PHP message: PHP  54. Illuminate\\Routing\\Router::toResponse() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:722
PHP message: PHP  55. Illuminate\\Http\\Response->__construct() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:750
PHP message: PHP  56. Symfony\\Component\\HttpFoundation\\ResponseHeaderBag->__construct() /vendor/symfony/http-foundation/Response.php:201
PHP message: PHP  57. Symfony\\Component\\HttpFoundation\\ResponseHeaderBag->initDate() /vendor/symfony/http-foundation/ResponseHeaderBag.php:41
PHP message: PHP  58. DateTime::createFromFormat() /vendor/symfony/http-foundation/ResponseHeaderBag.php:295
PHP message: PHP Fatal error:  DateTime::createFromFormat(): Timezone database is corrupt - this should *never* happen! in /vendor/symfony/http-foundation/ResponseHeaderBag.php on line 295
PHP message: PHP Stack trace:
PHP message: PHP   1. {main}() /public/index.php:0
PHP message: PHP   2. App\\Http\\Kernel->handle() /public/index.php:54
PHP message: PHP   3. App\\Http\\Kernel->sendRequestThroughRouter() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
PHP message: PHP   4. Illuminate\\Routing\\Pipeline->then() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
PHP message: PHP   5. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
PHP message: PHP   6. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP   7. App\\Http\\Middleware\\CheckForMaintenanceMode->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP   8. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
PHP message: PHP   9. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  10. Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  11. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
PHP message: PHP  12. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  13. App\\Http\\Middleware\\TrimStrings->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  14. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
PHP message: PHP  15. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  16. Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  17. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
PHP message: PHP  18. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  19. App\\Http\\Middleware\\TrustProxies->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  20. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/fideloper/proxy/src/TrustProxies.php:57
PHP message: PHP  21. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  22. Barryvdh\\Cors\\HandleCors->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  23. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/barryvdh/laravel-cors/src/HandleCors.php:36
PHP message: PHP  24. App\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
PHP message: PHP  25. Illuminate\\Routing\\Router->dispatch() /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
PHP message: PHP  26. Illuminate\\Routing\\Router->dispatchToRoute() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:614
PHP message: PHP  27. Illuminate\\Routing\\Router->runRoute() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:625
PHP message: PHP  28. Illuminate\\Routing\\Router->runRouteWithinStack() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:659
PHP message: PHP  29. Illuminate\\Routing\\Pipeline->then() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:684
PHP message: PHP  30. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
PHP message: PHP  31. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  32. App\\Http\\Middleware\\EncryptCookies->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  33. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
PHP message: PHP  34. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  35. Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  36. Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}() /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
PHP message: PHP  37. Illuminate\\Routing\\Pipeline->Illuminate\\Pipeline\\{closure}() /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
PHP message: PHP  38. Illuminate\\Session\\Middleware\\StartSession->handle() /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
PHP message: PHP  39. Illuminate\\Routing\\Pipeline->Illuminate\\Routing

[Thu Feb 21 13:07:41.819083 2019] [proxy_fcgi:error] [pid 19304] (104)Connection reset by peer: [client 59.547.36.85:57554] AH01075: Error dispatching request to :

但是当我在die('Working!')public/index.php时返回Working!。但是,当我删除该die Laravel会返回该错误!

我正在使用

PHP 7.2.14 Laravel Framework 5.7.27

我该如何解决?

1 个答案:

答案 0 :(得分:0)

如评论中所述,找到您的问题的关键在于以下通知:

date_default_timezone_set(): Timezone ID 'Asia/Tehran' is invalid

这与日志下方的致命错误有关:

DateTime::createFromFormat(): Timezone database is corrupt - this should *never* happen!.

时区数据库上的强调已损坏。 Laravel完全失败的原因是因为它试图创建与响应一起的时间戳记(可能是针对初始date_default_timezone_set通知的堆栈跟踪)。进而导致致命错误。您可以在致命错误上方的堆栈跟踪中看到这一点:

PHP message: PHP  55. Illuminate\\Http\\Response->__construct() /vendor/laravel/framework/src/Illuminate/Routing/Router.php:750
PHP message: PHP  56. Symfony\\Component\\HttpFoundation\\ResponseHeaderBag->__construct() /vendor/symfony/http-foundation/Response.php:201
PHP message: PHP  57. Symfony\\Component\\HttpFoundation\\ResponseHeaderBag->initDate() /vendor/symfony/http-foundation/ResponseHeaderBag.php:41
PHP message: PHP  58. DateTime::createFromFormat() /vendor/symfony/http-foundation/ResponseHeaderBag.php:295

要解决您的问题,您应该确切地找出为什么 PHP无法与时区数据库一起使用。可能有两个原因,但是要了解更多信息,您可以检查this question,其中包含一些答案。