Php.ini?


#1

I have a php script which crashes sometimes with Fatal error: Maximum execution time of 30 seconds exceeded in…

Is there a way to customize php.ini for my directory, so that I can extend that timeout limit?


#2

Firstly - what in heaven’s name are you running that pushes exec time past 30 seconds? If it’s just a massive hunka code, you may wanna consider breaking it down into smaller scripts and chaining them to execute consecutively somehow.

Secondly, I’ve been struggling a bit with how-to on php.ini settings myself. My own solution was to compile my own php.cgi and therefore have my own php.ini to fiddle with. However, since “max_execution_time” is listed as a PHP_INI_ALL variable, you may be able to get away with the following at the top of your script:ini_set("max_execution_time", 30); …and obviously upping the “30” to a higher number. The drag is that this’ll only work if the current php.ini doesn’t have “safe mode” enabled (use “phpinfo();” to check). If your current rig has safe mode enabled, you’ll be needing to visit the DH wiki on how to compile your own PHP run as cgi and edit your own php.ini appropriately.

But seriously, you should check into what’s causing the script to push that exec time first. I write some pretty strange stuff myself and the only time I’ve managed to break max_exec_time is through a fairly dumbarsed mistake in a looped set of mySQL queries, and chances are I probably caused no end of irritation to other users on that server and possibly some tech support folk while I was in the (6 hour) process of debugging the nasty thing (and “no”, wasn’t on a Dreamhost server so all you barbarians can re-sheath your knives now).
Just something to think about.


#3

You know what? The script crashed with the error this morning (I said sometimes, which is misleading), and I’m wondering if it wasn’t because the script wasn’t able to look up some data in the mysql database. I read after I posted that there were mysql problems this morning on DH servers so that my have been the culprit…