我正在制作一个 symfony 3.4 应用程序作为 REST 服务(所以我安装了常用的 JMS Serializer、FoSRest 和 lexik/jwt-authentication-bundle)并在 XAMPP(Windows 10)上对其进行测试。
当我使用 app_dev.php 作为端点通过我的前端应用程序发出 XHR 请求时,它(非常)经常发生 Apache 在同时发出 2 个以上的请求时崩溃。
在这里和那里阅读看起来这个问题通常是由尝试写入会话文件引起的,因为 symfony 默认会话处理程序是session.handler.native_file
.
所以我首先尝试放置null
(根据文档,它使用本机 PHP 会话处理程序),这使得崩溃发生的频率降低但没有完全解决问题
然后我尝试使用Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
这使得崩溃发生的次数比以前更少,但仍然偶尔会发生崩溃
现在我正在使用数据库作为会话处理程序,尽管我注意到当我发出 XHR 请求时没有在数据库上写入会话(虽然如果我打开应用程序提供的普通网页则它会这样做),这应该'让我感到惊讶,因为我设置了我security.yml
的 REST 路由必须是无状态的,但是玩弄handler_id
配置会影响我的 apache 崩溃的频率
如果我打开由同一个应用程序提供的多个网页,则不会发生同样的事情,如果我使用生产端点(app.php)也不会发生同样的事情。
有没有办法彻底解决这个问题?
编辑:根据要求
你能添加apache错误日志和php错误日志吗?
每次重新启动时,它都会像这样重复。我注意到了这条线:AH00428: Parent: child process 29076 exited with status 3221226356 -- Restarting.
这可能很有趣
[Sun Dec 17 00:39:58.548676 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00428: Parent: child process 22856 exited with status 3221226356 -- Restarting.
[Sun Dec 17 00:39:59.544151 2017] [ssl:warn] [pid 17564:tid 532] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:39:59.740710 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00455: Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/7.1.7 configured -- resuming normal operations
[Sun Dec 17 00:39:59.740710 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00456: Apache Lounge VC14 Server built: Jun 15 2017 12:39:41
[Sun Dec 17 00:39:59.740710 2017] [core:notice] [pid 17564:tid 532] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sun Dec 17 00:39:59.746705 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00418: Parent: Created child process 29076
[Sun Dec 17 00:40:01.201423 2017] [ssl:warn] [pid 29076:tid 592] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:01.414295 2017] [ssl:warn] [pid 29076:tid 592] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:01.455312 2017] [mpm_winnt:notice] [pid 29076:tid 592] AH00354: Child: Starting 150 worker threads.
[Sun Dec 17 00:40:17.006680 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00428: Parent: child process 29076 exited with status 3221226356 -- Restarting.
[Sun Dec 17 00:40:17.371667 2017] [ssl:warn] [pid 17564:tid 532] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:17.403690 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00455: Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/7.1.7 configured -- resuming normal operations
[Sun Dec 17 00:40:17.403690 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00456: Apache Lounge VC14 Server built: Jun 15 2017 12:39:41
[Sun Dec 17 00:40:17.403690 2017] [core:notice] [pid 17564:tid 532] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sun Dec 17 00:40:17.409694 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00418: Parent: Created child process 24332
[Sun Dec 17 00:40:18.667139 2017] [ssl:warn] [pid 24332:tid 524] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:18.858441 2017] [ssl:warn] [pid 24332:tid 524] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:18.895469 2017] [mpm_winnt:notice] [pid 24332:tid 524] AH00354: Child: Starting 150 worker threads.
[Sun Dec 17 00:40:20.972550 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00428: Parent: child process 24332 exited with status 3221226356 -- Restarting.
[Sun Dec 17 00:40:21.481091 2017] [ssl:warn] [pid 17564:tid 532] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:21.513627 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00455: Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/7.1.7 configured -- resuming normal operations
[Sun Dec 17 00:40:21.513627 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00456: Apache Lounge VC14 Server built: Jun 15 2017 12:39:41
[Sun Dec 17 00:40:21.513627 2017] [core:notice] [pid 17564:tid 532] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Sun Dec 17 00:40:21.519144 2017] [mpm_winnt:notice] [pid 17564:tid 532] AH00418: Parent: Created child process 27440
[Sun Dec 17 00:40:22.991094 2017] [ssl:warn] [pid 27440:tid 552] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:23.266105 2017] [ssl:warn] [pid 27440:tid 552] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Sun Dec 17 00:40:23.301132 2017] [mpm_winnt:notice] [pid 27440:tid 552] AH00354: Child: Starting 150 worker threads.
当你说 apache crash 意味着你必须重新启动 apache,或者你只是得到一个错误?你得到哪个错误?
我只是得到通常的应用程序崩溃窗口说“Apache 已停止工作”,如果我单击“关闭应用程序”它会自行重新启动,导致崩溃的请求只是失败,没有状态代码或错误消息(这是预期的,因为与服务器的连接停止)。如您所见,除了该状态代码外,日志中没有特定错误
你是如何设置 apache 和 php mod_apache、php-fpm 的?你有哪些 apache 服务器限制,有多少 php 工作者?
我不确定如何回答这个问题,我使用的是 XAMPP 包中的股票 apache 和 php,没有对配置进行编辑。我可以告诉你 php 是作为 apache 处理程序加载的,所以没有 CGI 或 FastCGI。无论如何在简单页面上或在 Symfony 中使用生产模式它都可以正常工作
消息:
我发现,由于我正在执行 CORS 请求,它正在为每个请求创建一个会话文件,我修复了这个问题并稍微改善了我的问题,但它仍然存在
我曾尝试使用 redis 作为 PHP 的会话处理程序,但它实际上让事情变得更糟
我做了一个简单的测试,我在同一个页面(使用会话)中调用了 1000 次,只要我把它放在
session_write_close();
最后,它就可以正常工作,否则它会崩溃