已解决,本地 Laravel 的调试页面加载缓慢打不开

感谢评论区 @largezhou 的解答,直接解决问题

直接贴出答案希望给有用的人看到
将 nginx 的配置,这是我原来的

fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;

修改成如下,就是调大 buffers 值

fastcgi_buffer_size 1024k;
fastcgi_buffers 16 256k;
fastcgi_busy_buffers_size 2048k;
fastcgi_temp_file_write_size 4096k;

下面是原来的问题

求解决,本地 Laravel 的调试页面加载缓慢打不开

本地开发环境为 Win10 WSL 安装的 Ubuntu 20 ,并安装的 Lnmp 开发环境,php 版本为 8.1
Composer 安装最新 Laravel 后,使用页面等一切正常
storage bootstrap/cache 权限也设置了 775

但就是有一个问题,开启了配置文件中的 Debug 为 true 后,调试页面一直在加载,加载长时间后停止,调试模式查看 url 最终返回 500
但是在调试页面右键查看源代码,打开正常

以下提供相关信息

php -m 查看扩展如下

[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]

Storage 下的 log 日志

[2023-04-10 07:43:00] local.ERROR: Symfony\Component\HttpKernel\Exception\HttpException::__construct(): Argument #1 ($statusCode) must be of type int, string given, called in /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 1224 {"exception":"[object] (TypeError(code: 0): Symfony\\Component\\HttpKernel\\Exception\\HttpException::__construct(): Argument #1 ($statusCode) must be of type int, string given, called in /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 1224 at /home/wwwroot/example-app/vendor/symfony/http-kernel/Exception/HttpException.php:24)
[stacktrace]
#0 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1224): Symfony\\Component\\HttpKernel\\Exception\\HttpException->__construct()
#1 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(45): Illuminate\\Foundation\\Application->abort()
#2 /home/wwwroot/example-app/routes/web.php(17): abort()
#3 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/CallableDispatcher.php(40): Illuminate\\Routing\\RouteFileRegistrar->{closure}()
#4 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(237): Illuminate\\Routing\\CallableDispatcher->dispatch()
#5 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(208): Illuminate\\Routing\\Route->runCallable()
#6 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(798): Illuminate\\Routing\\Route->run()
#7 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#8 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#9 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#10 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#11 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#12 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#13 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#14 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#15 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#16 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#17 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#18 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#19 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#20 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#21 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#22 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\\Pipeline\\Pipeline->then()
#23 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(776): Illuminate\\Routing\\Router->runRouteWithinStack()
#24 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(740): Illuminate\\Routing\\Router->runRoute()
#25 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(729): Illuminate\\Routing\\Router->dispatchToRoute()
#26 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#27 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#28 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#30 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#31 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#33 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#34 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#35 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#36 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#37 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#38 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#39 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#40 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#41 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#42 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#43 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#44 /home/wwwroot/example-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#45 /home/wwwroot/example-app/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#46 {main}
"} 

php 日志显示,长时间请求后,页面停止

[10-Apr-2023 15:39:11] WARNING: [pool www] child 1768, script '/home/wwwroot/example-app/public/index.php' (request: "GET ") execution timed out (131.666991 sec), terminating
[10-Apr-2023 15:39:11] WARNING: [pool www] child 1768 exited on signal 15 (SIGTERM) after 133.555864 seconds from start
[10-Apr-2023 15:39:11] NOTICE: [pool www] child 1811 started

从调试页面看,调试页面好像只加载了一部分,下面是调试浏览器页面截图

希望有经验大佬指点

PS:错误信息我是随便在路由 web.php 中返回个,测试调试页面用的

abort('aa');
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 11

你要么把xdebug关闭再试试,不行再把xdebug打开再试试,可能是这个的原因。

1个月前 评论
myoppo (楼主) 1个月前

nginx 对应的配置,修改成如下试试:

fastcgi_buffer_size 1024k;
fastcgi_buffers 16 256k;
fastcgi_busy_buffers_size 2048k;
fastcgi_temp_file_write_size 4096k;
fastcgi_buffering off;

就是把各种 buffer 调大了

1个月前 评论
myoppo (楼主) 1个月前
myoppo (楼主) 1个月前

abort(403);// abort这个函数必须传入整型,这是对的

而你 abort(‘aa’);// 传入字符串,laravel是不能理解的。

#2 /home/wwwroot/example-app/routes/web.php(17): abort()
1个月前 评论
myoppo (楼主) 1个月前

must be of type int, string given 翻译一下是:必须为int类型,给定字符串

1个月前 评论
myoppo (楼主) 1个月前

你这给我整不会了

# 日志只有 2 行(如果没有修改 vendor 目录的文件的话)
#2 /home/wwwroot/example-app/routes/web.php(17): abort()
#45 /home/wwwroot/example-app/public/index.php(52)

一开始我以为是 返回数据太多,然后出问题,看了日志应该不是这个引起的。

  1. /home/wwwroot/example-app/routes/web.php(17) 确认这个数据类型是否正确
  2. 多版本的情况,打印下 phpinfo , 确认用的是哪个版本
  3. 可以尝试弄个 空的 laravel, 看看慢不慢
  4. 浏览器一直 转圈就是在相应,传数据,看看有没有,如果没有应该是哪里报错,异常了,不是慢
  5. 可以 dd, 或 echo + exit; 强制退出看显示的内容是否正常,停在了哪一步

知道 laravel 的生命周期,这样方便调试

1个月前 评论
myoppo (楼主) 1个月前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!