I tried all the solutions on this page and, of course, ran from the command line:
php -f filename.php
as Brent says, a reasonable path around him.
But if you really want to run the script from your browser, which allows you to disable the timeout after 45 seconds with an internal server 500 error (as I found when restoring the phpBB search index), then there is a good chance called by mod_fcgid.
I have Plesk VPS and I fixed it by editing the file
/etc/httpd/conf.d/fcgid.conf
In particular, I changed
FcgidIOTimeout 45
to
FcgidIOTimeout 3600
3600 = 1 . , . , 7200 .
, Apache, .
apachectl graceful
HTH -. 6 !
,