PHP Fatal error: Allowed memory size of M bytes exhausted (tried to allocate N bytes) in

To fix PHP Fatal error: Allowed memory size of M bytes exhausted (tried to allocate N bytes) in /path/to/file.php PHP configuration parameter memory_limit should be changed respectively.

If PHP is runned as module (web server Apache). It can be done in .htaccess configuration file:

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value memory_limit 128M
</IfModule>

where 128M – is desired increased value.

Web server Apache should be restarted to apply new configuration parameter using command:

# /sbin/service httpd graceful

PHP values and flags can be customized in .htaccess only if no php_admin_flag or php_admin_value directives are set on virtual host configuration level.

If PHP is runned as CGI (FastCGI) php.ini configuration directive should be changed with desired value.