我最近在我的WordPress网站上注意到我有时会收到500内部服务器错误。我检查日志,我有很多线,如:WordPress致命错误:允许的内存大小536870912字节耗尽(试图分配77字节)在wp-includes/wp-db.php上线1832
[Mon Oct 03 01:25:24.357439 2016] [fcgid:warn] [pid 12840] [client 83.27.211.107:36968] mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 77 bytes) in /var/www/vhosts/mywebsite/public_html/wp-includes/wp-db.php on line 1832
我试图增加内存限制:
define('WP_MAX_MEMORY_LIMIT' , '512M');
define('WP_MEMORY_LIMIT' , '512M');
甚至更多,但没有奏效。无论我如何设置它仍然超过内存限制一些字节。我认为对数据库的某些查询存在问题,但如何检查哪些?
内容的包括/可湿性粉剂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;
}
所以问问自己**为什么**你需要在RAM中缓存500 + megs的数据。如果你需要,那么你的选择是提高/删除内存限制,或重建你的系统,所以你不需要同时在内存中那么多东西。否则,你基本上会问:“我把10升水倒进一个1升的水桶里,水溢出了,我怎么能让它溢出来?” –
您自己的服务器或虚拟主机? – markratledge
@MarcB,你不明白。我在我的网站上有一个错误。这是简单的WordPress网站,5个小部件,菜单和帖子循环(每页20个)。我不知道为什么这个超过内存的限制。 –