php - Apache/PHP/Win 内存问题,两种不同的系统+代码。同样的问题
问题描述
几个月来我一直在与这个问题作斗争。我有两个不同的系统,每个系统都有不同的设置和 PHP 代码,但都有完全相同的问题。
我的服务器将抛出 500 错误,并且日志将充满内存分配问题,直到重新启动 Apache。
系统一
操作系统:Windows 服务器 2008
XAMPP:PHP 7.1.9 / Apache 2.4.27
代码库:一个没有什么花哨的小型 laravel 网站
系统二
操作系统:Windows 服务器 2016
XAMPP:PHP 7.2.3.0 / Apache 2.4.29
代码库:一些长时间运行的 php 进程,大约 2 分钟。
阿帕奇错误
VirtualFree() 失败:[0x000001e7] 尝试访问无效地址。VirtualAlloc() 失败:[0x00000008] 没有足够的存储空间来处理此命令。VirtualFree() 失败:[0x000001e7] 尝试访问无效地址。
PHP 错误
[Mon May 21 09:27:42.078308 2018] [php7:error] [pid 10236:tid 12736] [client 43.245.8.13:1553] PHP 致命错误:内存不足(分配 2097152)(试图分配 6626884 字节) C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php 在第 141 行,引用者:http: //m.facebook.com/
[Mon May 21 09:28:12.703338 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63513] PHP 致命错误:内存不足(分配 73400320)(试图分配 4096 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php 在第 294 行
[Mon May 21 09:28:14.640812 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63529] PHP 致命错误:内存不足(分配 37748736)(试图分配 4096 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php 在第 294 行
[Mon May 21 09:28:19.218972 2018] [php7:error] [pid 10236:tid 12736] [client 157.49.220.122:64984] PHP 致命错误:内存不足(分配 20971520)(试图分配 4096 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php 在第 161 行,引用者:https ://www.facebook.com/
[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP 致命错误:内存不足(分配 12582912)(试图分配 131072 字节) C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php 在第 141 行
[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP 致命错误:内存不足(分配 12582912)(试图分配 32768 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php 在第 451 行
[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP 致命错误:内存不足(分配 12582912)(试图分配 20480 字节)第 0 行未知
什么触发了错误
这些错误似乎是随机发生的,但不是在 Apache 重新启动后立即发生。然而,就好像它占用了内存一样,我在服务器上有 6GB 的 8GB 空闲空间。
到目前为止我尝试过的
各种 php.ini 内存调整,例如memory_limit=1200M
脚本调整 ini_set('memory_limit', -1);
Apache 配置调整
ThreadStackSize 56*1024*1024
ThreadsPerChild 150
MaxConnectionsPerChild 0
RLimitMEM 99999999999 99999999999999
但是,我确实在重启后注意到它说
AH00118: RLimitMEM not supported on this platform
我已经看到这些错误散布在互联网上,似乎没有人找到解决方案。我需要 Windows 上的 PHP,我开始认为我应该尝试 IIS。
关于 Apache 配置还有什么其他建议或者我可以尝试什么?
解决方案
推荐阅读
- javascript - 嵌套的 bootstrap 5 手风琴不会折叠打开的面板
- git - 是否可以在不更改历史记录的情况下从 Git 中删除旧文件?
- python - 如果我全局使用 bind_all,我可以为某些小部件设置例外吗?
- javascript - 网络核心 Webapi/SignalR 应用程序被 CORS 策略阻止(带有网络框架 4.7.2 的网络核心 5。FE 消费者)
- javascript - 检测是否使用外部 JavaScript 文件创建了 html 元素
- vba - For...下一个语句范围
- netlogo - 无法根据 NetLogo 中的索引在列表中找到项目
- python - 使用 NiFi 生成带有日文字符的 XML 文件
- amazon-web-services - 如何在无服务器框架中为 Web 身份令牌设置 env
- django - Django中post_save信号的发送者和实例参数