How to extend the execution time of a php script?

I have a script and it takes a long time to complete.
In total, 30 seconds is given by default, this is stated in the logs.

[Thu Nov 10 00:07:48 2011] [error] [client] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/xxx/ on line 291

Where can I increase the execution time?

Answer 1, authority 100%

Maybe set_time_limit.

If set to 0, in addition, there is no limit on the script execution time.

Answer 2, authority 67%

In php.ini write:

max_execution_time = 60

Only this is not a panacea – after 60 seconds, some browsers drop the connection, and then apache kills the process

Answer 3, authority 50%

Try it in php
php ini_set("max_execution_time", "60");
or file .htaccess-> php_value max_execution_time 60.

Answer 4, authority 17%

To increase the script running time, write this at the beginning of the code (where the numbers are the script execution time in seconds)

ini_set('max_execution_time', '600');