Fatal error: Out of memory in WordPress running on AWS EC2?


I launch an instance (EC2): Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type
all the options are default (free tier), PHP 7.3.21 (cli) (built: Aug 21 2020 23:21:45) ( NTS )
and mysql Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using EditLine wrapper

In installed WordPress 5.5.1 and run it online for testing.

I configured as bellow :
sudo vim /etc/php.ini (php.ini file)

memory_limit = 1024M

I added two lines in wp-config.php

define('WP_MEMORY_LIMIT', '1024M');

Using .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
# END WordPress

<IfModule mod_php7.c>
php_value memory_limit 1024M

But sometimes I still get the error messages like:

Fatal error: Out of memory (allocated 28311552) (tried to allocate
65536 bytes) in Unknown on line 0


Fatal error: Out of memory (allocated 24117248) (tried to allocate
143360 bytes) in file…

Does anyone know how to fix this issue? Please help?
In php.ini file I see
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
before line
memory_limit = 1024M
Is that mean even I set memory_limit = 1024M the memory limit still is 128MB on EC2?

Le Trong Tan 2 years 2020-09-25T22:10:45-05:00 0 Answers 16 views 0

Leave an answer