使用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