PHP out of memory errors – Fatal error: Allowed memory size of XXX bytes exhausted

Check your PHP settings with an info.php file.

Throw this in your domain

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

 

If you control the server, edit the php.ini file defined in your phpinf(); – I’ll use nano to edit mine

# nano /etc/php5/apache2/php.ini

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 60
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 1024M

After you’ve made the changes restart apache. On my Ubuntu 10.x server I use

# service apache2 restart

If you don’t have access to the php.ini file you can make changes within your domain with the following changes; .htaccess, PHP or WordPress

.htaccess

Notice: This method will only work if PHP is running as an Apache module.

Find the “.htaccess” in your root directory of the specified domain, if there isn’t, create one. Put the following line in it.

php_value memory_limit 128M ; Change the 128M to your needs

WordPress

In your wp-config.php, find or add the following line:
define(‘WP_MEMORY_LIMIT’, ’64M’);

PHP

ini_set(‘memory_limit’, ‘128M’);

Leave a Reply

Your email address will not be published. Required fields are marked *