Tweaking PHP memory limit for Drupal & WordPress errors
Coming across PHP memory related error messages? Getting that annoying "Fatal Error - Allowed memory size exhausted" message?
Firstly, this could indicate that there is something wrong, like a problematic module or plugin that - due to a bug - is consuming too many resources and is over burdening the server. But, it might also be that everything is okay and that for the perfectly reasonable functionality you're running with your CMS you just need a bit more memory to run the PHP commands.
The PHPINFO command could help you figure out what specs you're currently configured for and adjust that upwards. You can create a PHP file with the following command and run it from your browser :
<?php phpinfo(); ?>
How to tweak that memory_limit settings? a few ways to do that.
If you have access to your PHP.INI file, you can add the following command (choose something like 16M, 32M and 64M, depending on your needs):
memory_limit = 32M
If you're on shared hosting, some providers allow a localized PHP.INI tweak by adding a PHP.INI file to the directory you're executing the PHP files from (if you're on root, then it's the public_html folder).
Another ways is by defining the variable through the .HTACCESS file. Open it with your FTP client in the CMS top directory and insert the following at the top :
php_value memory_limit 32M
Settings PHP file
If you want, you could also add the PHP directive in the CMS settings file, by adding the following to the relevant file (WordPress - WP-CONFIG.PHP, Drupal - SETTINGS.PHP under the relevant sites folder) :
Hope that helps somewhat. If you know of any other way or have something to correct/add, let me know.