Poetry of Programming

Because coding is art
  • rss
  • Home
  • Search

PHP Maximum execution time exceeded error workaround

Krzysztof Karolczak | Thursday July 24th, 2008

The Maximum execution time of 30 seconds exceeded error can be annoying when executing “heavy” PHP scripts (involving lots of data processing) and it’s also a frequent follow-up of running Apache web servers on Windows machines ;) (for example when testing Symfony projects on your local PC). But no worries! :) - there are couple of easy ways to solve this problem.

Solution 1 - When we have access to PHP configurations files.

If  we can edit the PHP config files the problem boils down to changing one variable in PHP.ini. Usually the right PHP.ini can be found in the main PHP dir (for example in my PHP WAMP intallation it’s located in C:\wamp\bin\php\php5.2.5). And now we just need to open it and look for the line:

max_execution_time = 30

Changing the 30 seconds setting to something like 120 seconds should do the trick. And all we need to do now is to restart the web server. :)

Solution 2 - On a remote server.

There is a nice PHP function called set_time_limit ( int $seconds ), every time it’s called it sets the timeout counter with the given value, which means that the script will now be able to run for $seconds. Execution of set_time_limit(0) removes the PHP timeout limit.

Unfortunately this will not work if PHP is running in safe mode. For further details consult the PHP manual.

Other timeout possibilities ;)

It’s also worth mentioning that most of webservers have their own timeout counters - e.g. in Apache it’s set to 300 s by default. 6 minutes is usually plenty of time but it still can be changed if we desire so :). The timeout setting can be found in httpd-default.conf file which is located with the rest of Apache conf files (e.g. my path is C:\wamp\bin\apache\apache2.2.6\conf\extra).

Categories
PHP
Tags
PHP, tips
Comments rss
Comments rss
Trackback
Trackback

« Symfoclipse - Symfony Development Tools for Eclipse Setting the web server to gain access to symfony_data/web/sf/ directory »

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Language

  • English
  • Polski


Navigation

  • css
  • PHP
  • Symfony
    • Installation

Blogroll

  • Symfony

Tags

css (1) eclipse (1) framework (1) PDT (1) PHP (4) Symfony (1) tips (1) vhost (1)

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox