记一次504 Gateway Time-out

使用curl请求是超时,查了下资料原来是端口被占用,造成了死锁,记录下

首先要知道为什么会出现死锁?

  在我们访问页面的时候这个端口进程就已经被使用,当我们再在页面中curl请求其他页面因为没有其他的端口,php-cgi当然还要使用9000,就造成了阻塞所以就死锁了。

运行环境:windows + nginx + php

解决方法:

打开cmd,执行

D:\App_self\phpstudy\PHPTutorial\php\php-7.0.12-nts\php-cgi.exe -b 127.0.0.1:9001 -c D:\App_self\phpstudy\PHPTutorial\php\php-7.0.12-nts\php.ini

注意,cmd窗口不要关闭

再在请求页的vhost配置文件中修改

        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

这里的fastcgi_pass要改成127.0.0.1:9001,即cmd开启的端口。

over

推荐一个nginx+php-cgi的运行原理,很不错,要常看

 http://www.cnblogs.com/mangguoxiansheng/p/5967745.html

 

posted @ 2019-03-28 15:59  谦逊的铅笔  阅读(1186)  评论(0编辑  收藏  举报