Learn how to fix the WordPress "Allowed memory size of ____ bytes exhausted" error by increasing the PHP memory limit on your Servidor Cloud running Linux.
- A Servidor Cloud running Linux (any distribution).
- WordPress and LAMP stack (Apache, MySQL, and PHP) installed and running.
WordPress running on a server is like any other program running on any form of computer: it requires a certain amount of memory to run. The harder WordPress is working, the more memory it will use.
WordPress has a default memory allocation rule in place to prevent the application from using up too much of a server's memory. This is a useful measure to prevent a broken script from using up all available server memory and crashing the server.
However, WordPress's memory limit defaults to a very conservative value: 64MB. This is often not enough for a WordPress installation which is receiving a lot of traffic in the form of visitors and/or comments.
Increase the PHP Memory Limit
To increase the PHP memory limit, you will need to edit your site's
wp-config.php file. This file is located at your WordPress installation's root directory. Edit this file, for example with the command:
sudo nano /var/www/html/wp-config.php
Add the following lines to the file, above the line which reads
// ** MySQL settings - You can get this info from your web host ** // :
/** Increase PHP memory limit */ define( 'WP_MEMORY_LIMIT', '256M' );
This will increase the memory limit to 256MB. You can customize the number to increase the memory limit to a higher amount if you wish.
Save and exit the file. Visit your site in a browser. The "memory exhausted" error will be gone. If the error is still occurring, you may need to increase the WordPress memory limit to a higher number, and/or increase the size of your server itself.