×ðÁú¿­Ê±

SwooleÓëNginx·´ÏòÊðÀíÓ븺ÔØƽºâµÄÍêÉÆÈÚºÏ

swooleÓënginx·´ÏòÊðÀíÓ븺ÔØƽºâµÄÍêÉÆÈÚºÏ

Ëæ×Å»¥ÁªÍøÓ¦ÓõÄÉú³¤ £¬Ëæ×Å»á¼ûÁ¿ºÍ²¢·¢Á¿µÄÔöÌí £¬¼òµ¥µÄÓ¦ÓóÌÐòÍùÍùÒѾ­ÎÞ·¨Öª×ãÐèÇó¡£ÎªÏàʶ¾öÕâ¸öÎÊÌâ £¬ÈËÃÇ×îÏÈʹÓøºÔØƽºâÊÖÒÕ £¬½«ÇëÇó·Ö·¢µ½¶à¸öЧÀÍÆ÷ÉÏ £¬´Ó¶øÌá¸ßϵͳºÍÓ¦ÓõĿÉÓÃÐÔºÍÎȹÌÐÔ¡£È»¶ø £¬²î±ðµÄ¸ºÔØƽºâÊÖÒÕÓвî±ðµÄÓÅÈõµã¡£µ±½ñ £¬SwooleºÍNginx·´ÏòÊðÀíÊǽÏÁ¿Ê¢ÐеĸºÔØƽºâÊÖÒÕ £¬ÔõÑù½«¶þÕßÍêÉÆÈÚºÏ £¬ÒÔʵÏÖ¸ü¸ßЧ¸üÎȹ̵ÄЧÀÍÄØ £¿

Ê×ÏÈ £¬NginxÊÇÒ»¸ö¸ßЧµÄ·´ÏòÊðÀíЧÀÍÆ÷ £¬³£ÓÃÓÚ¸ºÔØƽºâ¡£ÆäÖ÷Òª×÷ÓÃÊǽ«¿Í»§¶ËµÄÇëÇóת·¢µ½ºó¶ËµÄЧÀÍÆ÷ÉÏ £¬²¢½«ºó¶ËЧÀÍÆ÷µÄÏìÓ¦ÐÅÏ¢·µ»Ø¸ø¿Í»§¶Ë¡£¿ÉÊÇ £¬Nginx²¢²»¿É´¦Öóͷ£³¤ÅþÁ¬ºÍÒì²½IOµÈÎÊÌâ £¬Òò´Ë £¬SwooleÊ©Õ¹ÁËÖ÷ÒªµÄ×÷Óá£

SwooleÊÇÒ»¸ö»ùÓÚPHPÓïÑÔ¿ª·¢µÄÒì²½¡¢ÊÂÎñÇý¶¯µÄÍøÂçͨѶ¿ò¼Ü¡£Æä×î´óµÄÌصã¾ÍÊÇÖ§³ÖÒì²½IOºÍ³¤ÅþÁ¬ £¬¿ÉÒÔ³ä·ÖʹÓÃЧÀÍÆ÷µÄÐÔÄܺÍ×ÊÔ´¡£Swoole²»µ«Ö§³ÖHTTPЭÒé £¬»¹Ö§³ÖTCP¡¢UDP¡¢WebSocketµÈ¶àÖÖЭÒé £¬¿ÉÒÔÖª×ãÖݪֲî±ðµÄÓ¦Óó¡¾°¡£

½«SwooleºÍNginxÍŽáÆðÀ´Ê¹Óà £¬¿ÉÒÔ³ä·ÖÑéÕ¹ËüÃǸ÷×ÔµÄÓŵã¡£ÀýÈç £¬¿ÉÒÔͨ¹ýNginx·´ÏòÊðÀí½«ÇëÇó·Ö·¢µ½¶ą̀ºó¶ËЧÀÍÆ÷ÉÏ £¬´Ó¶øʵÏÖ¸ºÔØƽºâ £»Í¬Ê± £¬ÔÚÿ̨ºó¶ËЧÀÍÆ÷ÉÏ £¬Ê¹ÓÃSwooleÀ´´¦Öóͷ£ÇëÇó £¬¿ÉÒÔÌá¸ßЧÀÍÆ÷µÄÐÔÄܺÍÏìÓ¦ËÙÂÊ¡£

ÏÂÃæ £¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃSwooleºÍNginx·´ÏòÊðÀíÀ´ÊµÏÖ¸ºÔØƽºâºÍ¸ßÐÔÄܵÄWebЧÀÍ¡£

Ê×ÏÈ £¬ÐèҪװÖò¢ÉèÖÃNginx·´ÏòÊðÀíЧÀÍÆ÷¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄNginxÉèÖÃÎļþʾÀý£º

http {
    upstream backend {
        server 127.0.0.1:8000;
        server 127.0.0.1:8001;
        server 127.0.0.1:8002;
    }

    server {
        listen 80;
        server_name example.com;

        location / {
            proxy_pass http://backend;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖ¸¶¨Á˶ą̀ºó¶ËЧÀÍÆ÷ £¬½«ÇëÇó·Ö·¢µ½ÕâЩЧÀÍÆ÷ÉÏ¡£¼ÙÉèSwoole¼àÌýµÄ¶Ë¿ÚΪ8000¡¢8001¡¢8002µÈ £¬¿ÉÒÔÔÚÿ̨ЧÀÍÆ÷ÉÏÆô¶¯SwooleЧÀÍ¡£

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄSwoole HTTPЧÀÍÆ÷ʾÀý£º

<?php

$http = new swoole_http_server('127.0.0.1', 8000);

$http->on('request', function ($request, $response) {
    $response->header('Content-Type', 'text/plain');
    $response->end("Hello world
");
});

$http->start();

µÇ¼ºó¸´ÖÆ

µ±Óпͻ§¶ËÇëÇóµÖ´ïʱ £¬Swoole½«Òì²½µØ´¦Öóͷ£Õâ¸öÇëÇó £¬²¢·µ»ØÏìÓ¦¡£ÓÉÓÚSwooleÊÇÒì²½ºÍÊÂÎñÇý¶¯µÄ £¬¿ÉÒÔÖ§³Ö´ó¹æÄ£µÄ²¢·¢ÇëÇó £¬´Ó¶øÌá¸ßЧÀÍÆ÷µÄÐÔÄܺÍÏìÓ¦ËÙÂÊ¡£

ͨ¹ýÒÔÉϵÄÅäºÏ £¬ÎÒÃÇ¿ÉÒÔʵÏÖÒ»¸ö¸ßÐÔÄÜ¡¢¸ß¿ÉÓúͿÉÉìËõµÄWebЧÀÍ¡£ËäÈ» £¬ÔÚÏÖʵӦÓÃÖÐ £¬»¹ÐèҪ˼Á¿¸ºÔØƽºâËã·¨¡¢¶¯Ì¬À©ÈݺÍËõÈÝ¡¢Êý¾Ýͬ²½µÈÎÊÌâ¡£ÕâЩ¶¼ÐèҪƾ֤ÏêϸµÄÓ¦Óó¡¾°ºÍÐèÇó¾ÙÐÐÍýÏëºÍÉè¼Æ¡£

×ÜÖ® £¬SwooleºÍNginx·´ÏòÊðÀíÊÇÁ½¸öºÜÊÇÓÅÒìµÄÊÖÒÕ £¬ÍŽáÆðÀ´¿ÉÒÔʵÏÖ¸ü¸ßЧ¸üÎȹ̵ÄЧÀÍ¡£ÐÅÍÐËæ×Å»¥ÁªÍøÓ¦ÓõÄÉú³¤ £¬ÕâÁ½¸öÊÖÒÕµÄְλºÍÖ÷ÒªÐÔ½«»áÈÕÒæÌá¸ß¡£

ÒÔÉϾÍÊÇSwooleÓëNginx·´ÏòÊðÀíÓ븺ÔØƽºâµÄÍêÉÆÈںϵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿