解决WordPress的Fatal Error: Out of Memory

WordPress 偶尔出现 502 Bad Gateway 错误,通过查看日志,发现是 Fatal Error: Out of Memory 错误,也就是内存不足导致的,最好的解决方法就是直接升级服务器配置啦,如果你是VPS 或者 是共享主机,可以尝试下面的方法来解决:

方法一:You can even consider adding a line in .htaccess file which will resolve the issue.

php_value memory_limit 256M

就是在 .htaccess 文件中加上红色的那行字

方法二:Add this to your wp-config.php file:

define (‘WP_MEMORY_LIMIT’, ‘256M’ );

在你的 wp-config.php 文件中加上红色的那行字

方法三:wp-settings.php,编辑这个文件,修改define(‘WP_MEMORY_LIMIT’, ’32M’);为

define(‘WP_MEMORY_LIMIT’, ‘256M’);

方法四:在你的博客目录中添加一个 php.ini 文件,并且写入下面那行

memory_limit=256M

方法五:其实是方法四升级版:在你的博客目录中添加一个 php.ini 文件,并且写入下面的内容

register_globals=Off
safe_mode=off
magic_quotes_gpc=On
allow_url_include=Off
file_uploads=on
memory_limit=256M
max_executi alt=90
post_max_size=10M
upload_max_filesize=10M
max_input_time=300

如果以上加大内存的方法,还是不能够解决 Fatal Error: Out of Memory ,那你的WordPress可能某个插件 或 个功能,真的很耗内存,可以尝试用「WordPress插件:P3,找出拖慢网站的插件」排查。

标签:WordPress 发布于:2019-11-17 11:12:07