IIS 7 and Above
the php-cgi terminated after requesting on php 7.x via fastcgi in iis...
Last post Apr 16, 2018 10:16 AM by ejzhang
Apr 12, 2018 08:54 AM|ejzhang|LINK
I run php 7.1.16 (7.0.29) via fastcgi in iis 7.5, sometimes get 502 errors, i found the php-cgi terminated after requesting in resources monitor.
running environment: windows 2008 r2 + iis 7.5 + php 7.1.6 (7.0.29) x64
fastcgi configuration: maxInstances=100, InstanceMaxRequests=1000, PHP_FCGI_MAX_REQUESTS=1000
test script: for /l %a in (1,1,100) do curl http://127.0.0.1/phpinfo.php
for /l %a in (1,1,100) do curl http://127.0.0.1/phpinfo.php
Apr 12, 2018 04:00 PM|lextm|LINK
The test you carried out has nothing to do with those 502 errors.
Please dig IIS log files to find the 502 error records, such as
2011-04-04 10:05:14 W3SVC12004 PMCCESXWINPLN X.X.X.X GET /finder/connectors/php/connector_files.php _=1301911527471&cmd=open&target=&init=true&tree=true 80 - 188.8.131.52 HTTP/1.1 Mozilla/5.0+(Macintosh;+U;+PPC+Mac+OS+X+10_5_8;+es-es)+AppleWebKit/533.19.4+(KHTML,+like+Gecko)+Version/5.0.3+Safari/533.19.4
ewaadm=5fc88e7310f5133a72f675848eaa09dec833ffaf http://www.domain.ltd/finder/singlefile.php?field=test www.domain.ltd 502 2 259 1639 625 756
Only such can confirm the issue does come from IIS/PHP. After that you can follow articles such as https://docs.microsoft.com/en-us/iis/troubleshoot/diagnosing-http-errors/troubleshooting-http-5022-bad-gateway-error-in-cgi-applications to
analyze the actual errors.
Apr 13, 2018 02:41 AM|Yuk Ding|LINK
It depend on what 502 error you get. If you get 502.1 error in IIS, then you should check this link:
However, if you get 502.2, then you should take the steps in this document:
In addition, please ensure you have set the php cgi following this link:
You also need to check if this issue is caused by anti-virus/firewall.
Apr 13, 2018 06:16 AM|ejzhang|LINK
Thank you for the reply first! But the point isn't 502 errors, i think the because maybe is the php-cgi terminated after requesting, and refork it too slow.
Apr 13, 2018 09:02 PM|lextm|LINK
Performance monitor won't show much useful information about php-cgi.exe.
In your case, you should check Application event log or utilize WER, if php-cgi.exe does crash,
Besides, how did you get PHP installed on IIS? Try to run PHP Diagnostics and show the report here, https://www.jexusmanager.com/en/latest/tutorials/php-diagnostics.html
Apr 15, 2018 01:30 AM|ejzhang|LINK
Thank you very much!
But i think php-cgi doesn't crash, it is terminate normally, because the browser get the correct responses.
I try apache 2.4.33 + fastcgi + php 7 in the same environment, that all running normally, the php-cgi processes resident in memory.
I configurate the php on iis refer to official documents: https://docs.microsoft.com/en-us/iis/application-frameworks/scenario-build-a-php-website-on-iis/configuring-step-1-install-iis-and-php
Then same configuration in Windows 10 is running normally.
Apr 15, 2018 01:11 PM|lextm|LINK
What you configured on IIS side is just part of the equation. PHP has its own configuration which might interference,
As Microsoft has limited documentation on how to troubleshoot, you will have to check if PHP itself has certain logging on how to track php-cgi.exe recycle events. That might help reveal the cause.
There is also a possibility that hotfixes are needed, if you Google "fastcgi site:support.microsoft.com
windows server 2008".
Apr 16, 2018 10:16 AM|ejzhang|LINK
I cann't found any messages in IIS logging about fastcgi or php, i enabled errors logging in php.ini, and hasn't any things in php_errors.log.
iis fastcgi configuration:
php.ini configuration about logging:
error_reporting = E_ALL
display_errors = Off
log_errors = On
error_log = d:/inetpub/logs/logfiles/php_errors.log
@for /l %a in (1,1,1000) do @ping -n 1 127.0.0.1 > nul && @curl http://127.0.0.1/phpinfo.php