• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Windows下nginx+fastcgi+php的并发阻塞问题

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

首先在nginx.conf中进行如下配置:

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  60;
    underscores_in_headers on;
    include otherconf/*.conf;
    include hlyunbackend/*.conf;

    client_max_body_size 20m;
	add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Headers X-Requested-With;
    add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;  


  #额外启动多个php-cgi去处理并发请求
    upstream fastcgi_proxy{
        server 127.0.0.1:9000;
        server 127.0.0.1:9001;
        server 127.0.0.1:9002;
        server 127.0.0.1:9003;
        server 127.0.0.1:9004;
        server 127.0.0.1:9005;
        server 127.0.0.1:9006;
        server 127.0.0.1:9007;
        server 127.0.0.1:9008;
        server 127.0.0.1:9009;
        server 127.0.0.1:9010;
        server 127.0.0.1:9011;
        server 127.0.0.1:9012;
        server 127.0.0.1:9013;
        server 127.0.0.1:9014;
        server 127.0.0.1:9015;
        server 127.0.0.1:9016;
        server 127.0.0.1:9017;
        server 127.0.0.1:9018;
        server 127.0.0.1:9019;
        server 127.0.0.1:9020;
        server 127.0.0.1:9021;
        server 127.0.0.1:9022;
        server 127.0.0.1:9023;
        server 127.0.0.1:9024;
        server 127.0.0.1:9025;


    }
}

  

再把所有

fastcgi_pass 127.0.0.1:9000;

改为

fastcgi_pass phpfastcgi_proxy;

 

server {
        listen       7000;
        server_name  localhost;
        location / {
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With;
            add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
            root   E:/www/htms3/hlyun_sso/public;
            index  index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }
        error_page   500 502 503 504  /50x.html;
        location ~ \.php$ {
			root           E:/www/htms3/hlyun_sso/public;
            fastcgi_pass   fastcgi_proxy;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

  

保存,重启Nginx。

开启cgi端口(.bat 文件):

taskkill /F /IM nginx.exe > nul
taskkill /F /IM php-cgi.exe > nul
@echo off
echo Starting nginx...
E:\nginx\RunHiddenConsole.exe E:\nginx\nginx.exe -p E:\nginx
echo Starting PHP FastCGI...
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9000 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9001 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9002 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9003 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9004 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9005 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9006 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9007 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9008 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9009 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9010 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9011 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9012 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9013 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9014 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9015 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9016 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9017 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9018 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9019 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9020 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9021 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9022 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9023 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9024 -c C:\php\php.ini
E:\nginx\RunHiddenConsole.exe C:\php\php-cgi.exe -b 127.0.0.1:9025 -c C:\php\php.ini

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP+CI框架+Memcache集成发布时间:2022-07-10
下一篇:
php.ini文件修改完重启发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap