wordpress 前台或后台出现 Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate xxx bytes) in xxx.php on line xxx 的解决办法
打开 wp-includes 目录下 default-constants.php 文件,找到如下代码
// set memory limits
if (!defined(‘WP_MEMORY_LIMIT’) ) {
if(is_multisite() ) {
define(‘WP_MEMORY_LIMIT’, ’64M’);
} else {
define(‘WP_MEMORY_LIMIT’, ’32M’);
}
}if (! defined( ‘WP_MAX_MEMORY_LIMIT’) ) {
define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);
}
然后把 define(‘WP_MEMORY_LIMIT’, ’32M’); 这个 32M 修改为 64M,保存,覆盖原来的文件,修改后如下图:
如果还是不行,可以修改成 96M、128M 或更大。
注意:请不要使用 Windows 系统自带的记事本修改代码,推荐使用 Notepad++、UltraEdit、EditPlus 等编辑器修改,cPanel 用户可以直接在 cPanel 文件管理器 Edit。
正文完