2012-09-19 00:53
浏览 283


For the life of me, I can't figure this out.

This is my development machine setup:

Windows 7 Home Premium 64 bit,
Webserver: NGINX 1.3.6 c:\users\user_name\devel ginx
PHP: 5.4.7 c:\users\user_name\devel ginx\php5

Everything works fine except that after exactly 500 hits, my php-cgi.exe quits unexpectedly. No error logs, no events, nothing. It just dies after 500 hits...EVERY SINGLE TIME. I haven't found a single source of information online to help me on this. All the configuration seems valid and good. This is happening on two different machines (my development desktop and my notebook). I've tried different nginx.conf and php.ini files...still the same.

I just need to get a better idea on how to go about debugging this. Any suggestions?

图片转代码服务由CSDN问答提供 功能建议



Windows 7 Home Premium 64位,
网络服务器:NGINX 1.3.6 c:\ users \ user_name \ devel ginx
\ nPHP:5.4.7 c:\ users \ user_name \ devel ginx \ php5

一切正常,但在经过500次点击后,我的php-cgi.exe意外退出。 没有错误日志,没有事件,没有。 它只是在500次点击后死亡......每一次都是。 我没有在网上找到一个单一的信息来源来帮助我。 所有配置似乎都有效且良好。 这发生在两台不同的机器上(我的开发台式机和笔记本电脑)。 我尝试了不同的nginx.conf和php.ini文件......仍然是一样的。

我只需要更好地了解如何调试它。 有什么建议吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • duanqiao1880 2012-10-22 22:01

    I finally figured it out. Maybe it was simple enough that I couldn't find the solution.



    to the command file that launches the php-cgi.exe fixed it. I guess it defaults (when not set) to 500 hits before FCGI is killed.

    Obviously, there are good reasons for this and as GargantuChet has suggested, settings things up correctly and letting the instances of PHP managed and auto-spawn is a better way to go...but for people who want a quick windows development environment, this can solve some problems.

    打赏 评论
  • dsns47611 2012-10-30 21:57

    unvisible EXE file that will LOOP-RUN php-cgi.exe with passing it own command-line params, can be easily compiled in, for example, ms-VCpp6 (phpCgiExeLoop.exe ~28kb):

    #include <windows.h>
    #include <Shellapi.h>
    #include "stdio.h"
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,      int       nCmdShow)
    {   while (1)
        {   SHELLEXECUTEINFO shExInfo = {0};
            shExInfo.cbSize = sizeof(shExInfo);
            shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;   shExInfo.hwnd = 0;
            shExInfo.lpVerb = "open";            // Operation to perform
            shExInfo.lpFile = "php-cgi.exe";     // Application to start    
            shExInfo.lpParameters = lpCmdLine;   // Additional parameters
            shExInfo.lpDirectory = 0;            shExInfo.nShow = SW_HIDE;
            shExInfo.hInstApp = 0;  
            if (ShellExecuteEx(&shExInfo))
            {   WaitForSingleObject(shExInfo.hProcess, INFINITE);
        return 0;

    and running "phpCgiExeLoop -b" instead of "php-cgi.exe -b" win-support php creators intention (avoiding possible memory-leaks).

    打赏 评论
  • duandie5707 2015-12-24 22:19

    The selected answer works, but doesn't allow the CGI server to shut down every so often (after 500 hits in the OPs case).

    Like the OP and others mentioned, this shutdown is necessary in a production environment to curtail memory leaks.

    In Windows, another solution is to create a batch file that looks like this:

        php-cgi -b
        goto start

    This will allow the shutdown that was designed to occur, and will almost immediately start php-cgi again.

    打赏 评论
  • drtzb06222 2019-05-29 14:39

    If you add


    to the command file that launches the php-cgi.exe, it fixed it.

    You can add more children if you want, it depends of your need.

    打赏 评论

相关推荐 更多相似问题