When executing and running PHP script, the PHP script may fail to complete properly and then return HTTP status code 500, indicating Internal Server Error.

Internet Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, email_address@techjourney.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

500 Internal Server Error

In web server error log, the PHP web app which is assigned to the handler fcgid-script for execution through FastCGI protocol provided by mod_fcgid, has the errors similar to the following logged:

[Wed Apr 08 02:20:25 2015] [warn] [client] mod_fcgid: read data timeout in 31 seconds, referer: https://techjourney.net/
[Wed Apr 08 02:20:25 2015] [error] [client] Premature end of script headers: app.php, referer: https://techjourney.net/

The error indicates that the PHP script had hit its maximum execution time limit, and was terminated before completing its operating gracefully. Increase the time given to PHP scripts to run in order to resolve the issue.

To increase time limit for PHP execution, modify the following option in php.ini PHP configuration file (if you’re using custom php.ini file for domain or website, change the custom php.ini instead of global php.ini):


max_execution_time sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. The purpose of the setting to to prevent poorly written scripts from eating up system resources. The default duration a PHP script is allowed to run is 30 seconds, but many scripts may require more than 30 seconds. For example, to allow maximum execution time of 300 seconds, change the value to:

; Maximum execution time of each script, in seconds
; http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
max_execution_time = 300

Restart the Apache HTTPD server when for the changes to take effect.

Other than PHP timeout limit, the web server can have other timeout configurations. If the PHP script execution is FCGId, then the other primary timeout limit a PHP script will hit is from FastCGI protocol, especially IPCCommTimeout, or its new name FcgidIOTimeout.

FcgidIOTimeout or IPCCommTimeout sets the maximum period of time the module will wait while trying to read from or write to a FastCGI application. To allow applications to take a longer time to respond, increase the value of the directive in Apapche configuration file, httpd.conf , or other included config files that contain the above directives, including within the virtual hosts configuration.


FcgidIOTimeoute = 300


IPCCommTimeout = 300
In Virtualmin control panel, select the virtual server that is affected (i.e. has to increase the timeout), and then go to Server Configuration -> Website Options. Set the appropriate value for Maximum PHP script run time as the new duration which PHP apps are allowed to run before was forced to terminate.

Set PHP Maximum Execution Time Limit

Virtualmin is smart enough to change both the maximum execution timeout value in PHP.INI and the FCGId timeout value in httpd.conf, as well as both HTTP and HTTPS (SSL) sites if you have both, and then restart the Apache web server for the change to take effect.