WordPress Apache VirtualAlloc和VirtualFree失败,PHP内存不足 [英] WordPress Apache VirtualAlloc and VirtualFree failed, PHP out of memory

查看:285
本文介绍了WordPress Apache VirtualAlloc和VirtualFree失败,PHP内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用统一服务器 WAMP软件包(Apache 2.4.20版)独自托管一些网页,PHP版本7.0.8),其中一个是简单的 Bootsrap 产品组合,另一个是 WooCommerce 等插件.

I am trying to host a few webpages by myself using Uniform Server WAMP package (Apache version 2.4.20, PHP version 7.0.8), one of them is a simple Bootsrap portfolio and another is a WordPress based online shop using WooCommerce and other plugins.

我的基于WordPress的网站有时会停止工作,直到我重新启动Apache服务为止.我发现主Apache日志充满了以下错误:

From time to time my WordPress based site stops working until I restart Apache service. I find main Apache log filled with these errors:

VirtualAlloc()失败:[0x00000008]没有足够的存储空间可用于处理此命令. VirtualFree()失败:[0x000001e7]尝试访问无效的地址.

VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command. VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

我的商店Apache错误日志中都包含以下内容:

And my shops Apache error log full of these:

[2016年8月23日星期二14:49:59.357235] [:错误] [pid 11300:tid 1768] [客户端88.119.96.56:52269] PHP致命错误:内存不足(已分配2097152)(试图分配4096字节) ),在第276行的D:\ Software \ UniServerZ \ vhosts \ *** \ wp-includes \ pomo \ mo.php中,请参阅:http://***/wp-admin/edit.php?post_type = shop_order

[Tue Aug 23 14:49:59.357235 2016] [:error] [pid 11300:tid 1768] [client 88.119.96.56:52269] PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 4096 bytes) in D:\Software\UniServerZ\vhosts\***\wp-includes\pomo\mo.php on line 276, referer: http://***/wp-admin/edit.php?post_type=shop_order

行与268、270和276不同,在mo.php中,它们看起来像这样:

lines differ to 268, 270 and 276, and in mo.php they look like this:

$entry = new Translation_Entry(); // 268
...
$parts = explode(chr(4), $original); // 270
...
$parts = explode(chr(0), $original); // 276

可以找到整个源代码这里.

与此同时,我的投资组合页面正常运行.

In the meantime my portfolio page works without issues.

我将 php.ini 中的memory_limit增加到2048MB,向 wp-config.php 中添加了define('WP_MEMORY_LIMIT', '256M');define('WP_MAX_MEMORY_LIMIT', '512M');,但是仍然每周至少两次我的网站无法访问,并且记录了上面提到的消息.

I increased memory_limit in php.ini to 2048MB, added define('WP_MEMORY_LIMIT', '256M'); and define('WP_MAX_MEMORY_LIMIT', '512M'); to wp-config.php, but still at least two times a week my website is not accessible and logs full of messages mentioned above.

我的网站流量不大,服务器具有16GB的RAM和半空的512GB SSD,请帮助我了解或找出造成此问题的原因,因为当前的日志对我来说很少.

My sites do not generate much traffic, server has 16GB of RAM and half-empty 512GB SSD, please help me understand or find out what is causing the issue because current logs say very little to me.

更新1

我在所有VirtualAlloc和VirtualFree失败之前发现了一条有趣的线:

I found an interesting line above all those VirtualAlloc and VirtualFree fails:

[2016年8月23日星期二21:02:40.298272] [:错误] [pid 504:tid 1836] [客户端191.96.249.54:36032]脚本'D:/Software/UniServerZ/www/xmlrpc.php'未找到或无法统计

[Tue Aug 23 21:02:40.298272 2016] [:error] [pid 504:tid 1836] [client 191.96.249.54:36032] script 'D:/Software/UniServerZ/www/xmlrpc.php' not found or unable to stat

好像我是黑客攻击的受害者,通过将以下行添加到.htaccess文件中来禁用了xmlprc:

Looks like I was a victim of hacking attempt, disabled xmlprc by adding these lines to .htaccess file:

<Files "xmlrpc.php">
Order Allow,Deny
Deny from all
</Files>

希望这会有所帮助.

更新2-几天后

看起来问题已经解决,我不时发现客户端因服务器配置错误而被拒绝,但是网站不再失败.

Looks like issue is resolved, from time to time I find client denied by server configuration errors, but website no longer fails.

更新3-几周后

VirtualAlloc()和VirtualFree()失败又回来了,没有任何可疑的脚本请求,日志中只写满了提到的失败,我的商店日志中有很多提到的内存不足错误.能否通过某种方式使Apache错误更详细/更详细,以找出哪些命令触发了不足的存储错误,或试图访问哪个无效地址?

VirtualAlloc() and VirtualFree() fails are back, without any suspicious script requests, log is just full of mentioned fails and my shops log has bunch of mentioned out of memory errors. Is it possible to some how make Apache errors more verbose/detailed to figure out what command triggers the not enough storage error, or what invalid address was attempted to access?

更新4-几个月后

经过一段时间的常规网站使用并不时重新启动Apache之后,错误才刚刚停止,我怀疑某些使用过的插件已更新,并且内存不会泄漏,并且一切正常,直到出现下一个错误...

After some time of regular website usage and restarting the Apache from time to time the errors just stopped, I suspect some of used plugins has been updated and now memory doesn't leak and everything works until next error...

推荐答案

由于WordPress不使用PHP本机会话,因此不确定这样做是否有帮助, 但可能是某些插件正在使用.

Not sure this is can help as WordPress does not use PHP native sessions, but can be, that some plugins are using.

我的情况: Windows OS,PHP 7.0.6-7.0.11
由于php会话的使用,VirtuaAlloc失败. http://php.net/manual/en/features.sessions.php 我已经用我自己的所有php session_函数删除/替换了.

My situation: Windows OS, PHP 7.0.6 - 7.0.11
VirtuaAlloc fails due the php session usage. http://php.net/manual/en/features.sessions.php I've removed/replaced all php session_ functions with mine own.

如何复制: session_start(); 解析一些巨大的xml(150MB或更多)文件 确实可以同时在Apache服务器上运行同一脚本多次.

Howto reproduce: session_start(); do parse some huge xml (150MB or more) file do run multiple times same script at the same time on the Apache server.

这篇关于WordPress Apache VirtualAlloc和VirtualFree失败,PHP内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆