I launch an instance (EC2): Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type all the options are default (free tier) In installed Wordpress and run it online for test.
I configured as bellow: sudo vim /etc/php.ini (php.ini file)
memory_limit = 1024M
I added two line in wp-config.php
define('FS_METHOD','direct');
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]
</IfModule>
# END WordPress
<IfModule mod_php7.c>
php_value memory_limit 1024M
</IfModule>
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
or
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 linememory_limit = 1024M
Is that mean even I set memory_limit = 1024M the memory limit still is 128MB on EC2?
define('WP_MEMORY_LIMIT', '1024M');
memory_limit = 1024M;
php_value memory_limit 1024M
PS: Try restarting the PHP service as well
It looks like your wordpress needs more memory to run than you have given, which is 256M. Now solution is to optimize your wordpress like remove un-necessary plugins / themes etc. Use proper caching and CDN. But if still it gives error then try to increase the instance type to next level. Like from t2.nano to t2.micro
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.