How to change the maximum execution time and memory size allowed for PHP

I see this message in the error log of httpd:

PHP Fatal error:  Maximum execution time of 30 seconds exceeded in


PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted 

How to change them to a longer and larger value?

asked Jul 31, 2013 by EricaS. (210 points)

1 Answer

To change the allowed maximum memory usage of PHP:


memory_limit = 256M

in /etc/php.ini.

To change the maximum allowed execution time of PHP:


max_execution_time = 300

in /etc/php.ini.

You can also set these values in .htaccess if it is allowed by the server. For example, to set the memory_limit:

php_value memory_limit 256M

You can also set the values in the PHP script:

ini_set('memory_limit', '256M');

Some programs has internal defined variables. For example, WordPress has an configuration variable that can be defined in wp-config.php:

define('WP_MEMORY_LIMIT', '256M');
answered Jul 31, 2013 by anonymous

Please log in or register to answer this question.

Related questions

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost