我最近注意到我的 WordPress 网站有时会收到 500 内部服务器错误。我检查了日志,有很多行,例如:
[2016 年 10 月 3 日星期一 01:25:24.357439] [fcgid:警告] [pid 12840] [客户端
83.27.211.107:36968] mod_fcgid: stderr: PHP 致命错误: 允许的内存大小 536870912 字节已耗尽(尝试分配 77 字节)
在 /var/www/vhosts/mywebsite/public_html/wp-includes/wp-db.php 在线
1832年
我尝试增加内存限制:
定义('WP_MAX_MEMORY_LIMIT','512M');
定义( 'WP_MEMORY_LIMIT' , '512M' );
甚至更多,但它不起作用。无论我设置什么,它仍然超出内存限制一些字节。我认为对数据库的某些查询存在问题,但如何检查哪些查询?
include/wp-db.php 的内容:
} else {
$num_rows = 0;
if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
while ( $row = mysqli_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
} elseif ( is_resource( $this->result ) ) {
// server crashing at line below
while ( $row = mysql_fetch_object( $this->result ) ) {
$this->last_result[$num_rows] = $row;
$num_rows++;
}
}
// Log number of rows the query returned
// and return number of rows selected
$this->num_rows = $num_rows;
$return_val = $num_rows;
}
该问题是由 iThemes Security 插件引起的。我把它关掉了,错误就消失了。如果我知道这个插件的哪个部分导致超出内存限制,我将进一步调查这个问题并编辑这个答案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)