{"id":17,"date":"2024-05-28T19:49:13","date_gmt":"2024-05-28T11:49:13","guid":{"rendered":"http:\/\/www.yixi.ltd\/?p=17"},"modified":"2024-05-28T19:49:13","modified_gmt":"2024-05-28T11:49:13","slug":"swoole","status":"publish","type":"post","link":"https:\/\/www.bengbu.host\/?p=17","title":{"rendered":"Swoole"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Swoole \u4f7f PHP \u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u7f16\u5199\u9ad8\u6027\u80fd\u9ad8\u5e76\u53d1\u7684 TCP\u3001UDP\u3001Unix Socket\u3001HTTP\u3001 WebSocket \u7b49\u670d\u52a1\uff0c\u8ba9 PHP \u4e0d\u518d\u5c40\u9650\u4e8e Web \u9886\u57df\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u51b3php -v\u67e5\u770b\u5230\u7248\u672c\u4e0ephpinfo()\u7248\u672c\u4e0d\u4e00\u81f4\u95ee\u9898 \u4ee5\u5b9d\u5854\u4e3a\u4f8b \u5b89\u88c5php7,2\u540e\u53d1\u73b0phpinfo\u7684\u7248\u672c\u662f7.2.18\uff0c\u800cphp -v\u67e5\u770b\u7684\u5374\u662f5.4.45&nbsp;php\u2212v\ud835\udc5d\u210e\ud835\udc5d\u2212\ud835\udc63&nbsp;find \/ -name php.ini&nbsp;php\u2212i|grepphp.ini\ud835\udc5d\u210e\ud835\udc5d\u2212\ud835\udc56|\ud835\udc54\ud835\udc5f\ud835\udc52\ud835\udc5d\ud835\udc5d\u210e\ud835\udc5d.\ud835\udc56\ud835\udc5b\ud835\udc56&nbsp;vi \/etc\/profile \/\/\u6700\u540e\u4e00\u884c\u6dfb\u52a0 export PATH=&#8221;\/www\/server\/php\/72\/bin:PATH&#8221;\/\/\u4e34\u65f6\u6dfb\u52a0\uff0c\u76f4\u63a5\u6267\u884c\ud835\udc43\ud835\udc34\ud835\udc47\ud835\udc3b&#8221;\/\/\u4e34\u65f6\u6dfb\u52a0\uff0c\u76f4\u63a5\u6267\u884c&nbsp;wq $ source \/etc\/profile<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u4e0b\u8f7d\u5b89\u88c5\u5305 $ sudo wget&nbsp;<a href=\"https:\/\/gitee.com\/link?target=https%3A%2F%2Fgithub.com%2Fswoole%2Fswoole-src%2Farchive%2Fv4.8.10.tar.gz\">https:\/\/github.com\/swoole\/swoole-src\/archive\/v4.8.10.tar.gz<\/a>&nbsp;$ sudo tar zxvf v4.8.10.tar.gz<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.\u7f16\u8bd1\u5b89\u88c5 \u4f7f\u7528\u5b89\u88c5 php \u65f6\u751f\u6210\u7684 phpize \u6765\u751f\u6210 configure \u914d\u7f6e\u6587\u4ef6\uff08\u53ef\u4ee5\u7528 whereis phpize\u67e5\u770b\u8def\u5f84\uff0c\u5176\u4e2d php-config \u548c phpize \u6240\u5728\u7684\u76ee\u5f55\u662f\u76f8\u540c\u7684\uff09&nbsp;cdswoole\u2212src\u22124.8.10\ud835\udc50\ud835\udc51\ud835\udc60\ud835\udc64\ud835\udc5c\ud835\udc5c\ud835\udc59\ud835\udc52\u2212\ud835\udc60\ud835\udc5f\ud835\udc50\u22124.8.10&nbsp;phpize (centos \u6ca1\u6709\u5b89\u88c5phpize\u53ef\u6267\u884c\u547d\u4ee4\uff1ayum install php-devel\u6765\u5b89\u88c5phpize)&nbsp;.\/configure\u2212\u2212with\u2212php\u2212config=\/www\/server\/php\/74\/bin\/php\u2212config.\/\ud835\udc50\ud835\udc5c\ud835\udc5b\ud835\udc53\ud835\udc56\ud835\udc54\ud835\udc62\ud835\udc5f\ud835\udc52\u2212\u2212\ud835\udc64\ud835\udc56\ud835\udc61\u210e\u2212\ud835\udc5d\u210e\ud835\udc5d\u2212\ud835\udc50\ud835\udc5c\ud835\udc5b\ud835\udc53\ud835\udc56\ud835\udc54=\/\ud835\udc64\ud835\udc64\ud835\udc64\/\ud835\udc60\ud835\udc52\ud835\udc5f\ud835\udc63\ud835\udc52\ud835\udc5f\/\ud835\udc5d\u210e\ud835\udc5d\/74\/\ud835\udc4f\ud835\udc56\ud835\udc5b\/\ud835\udc5d\u210e\ud835\udc5d\u2212\ud835\udc50\ud835\udc5c\ud835\udc5b\ud835\udc53\ud835\udc56\ud835\udc54&nbsp;make $ sudo make install<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3.php.ini\u5f00\u542fswoole\u6269\u5c55 \u7f16\u8bd1\u5b89\u88c5\u6210\u529f\u540e\uff0c\u4fee\u6539php.ini\u52a0\u5165 extension=swoole.so \u901a\u8fc7php -m\u6216phpinfo()\u6765\u67e5\u770b\u662f\u5426\u6210\u529f\u52a0\u8f7d\u4e86swoole.so\uff0c\u5982\u679c\u6ca1\u6709\u53ef\u80fd\u662fphp.ini\u7684\u8def\u5f84\u4e0d\u5bf9\uff0c\u53ef\u4ee5\u4f7f\u7528php &#8211;ini\u6765\u5b9a\u4f4d\u5230php.ini\u7684\u7edd\u5bf9\u8def\u5f84\u3002 php -m |grep swoole<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">phpthinkswoole\u2212d\ud835\udc5d\u210e\ud835\udc5d\ud835\udc61\u210e\ud835\udc56\ud835\udc5b\ud835\udc58\ud835\udc60\ud835\udc64\ud835\udc5c\ud835\udc5c\ud835\udc59\ud835\udc52\u2212\ud835\udc51&nbsp;php think swoole stop<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u5f00\u542fswoole\u6269\u5c55\u4f1a\u51fa\u73b0\u4e0b\u5217\u9519\u8bef Use of undefined constant SWOOLE_PROCESS &#8211; assumed &#8216;SWOOLE_PROCESS&#8217; (this will throw an Error in a future version of PHP)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{ &#8220;url&#8221;:&#8221;plugin\/layim\/index\/send&#8221;, &#8220;type&#8221;:&#8221;chatMessage&#8221;, &#8220;arguments&#8221;:{ &#8220;mine&#8221;: { &#8220;username&#8221;:&#8221;\u6dd8\u8d4f\u6d4b\u8bd5&#8221;, &#8220;avatar&#8221;:&#8221;<a href=\"https:\/\/gitee.com\/link?target=http%3A%2F%2Fcdn.firstlinkapp.com%2Fupload%2F2016_6%2F1465575923433_33812.jpg\">http:\/\/cdn.firstlinkapp.com\/upload\/2016_6\/1465575923433_33812.jpg<\/a>&#8220;, &#8220;id&#8221;:26, &#8220;mine&#8221;:true, &#8220;content&#8221;:&#8221;haha&#8221; }, &#8220;to&#8221;:{ &#8220;username&#8221;:&#8221;wmainng&#8221;, &#8220;id&#8221;:28, &#8220;avatar&#8221;:&#8221;<a href=\"https:\/\/gitee.com\/link?target=http%3A%2F%2Fcdn.firstlinkapp.com%2Fupload%2F2016_6%2F1465575923433_33812.jpg\">http:\/\/cdn.firstlinkapp.com\/upload\/2016_6\/1465575923433_33812.jpg<\/a>&#8220;, &#8220;sign&#8221;:&#8221;&#8221;, &#8220;name&#8221;:&#8221;zhoutong&#8221;, &#8220;type&#8221;:&#8221;friend&#8221; } } }<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">wss\u914d\u7f6e \u5728nginx\u4e2d\u914d\u7f6ewss\u65b9\u6cd5 #wss\u534f\u8bae\u8f6c\u53d1 \u5c0f\u7a0b\u5e8f\u91cc\u9762\u8981\u8bbf\u95ee\u7684\u94fe\u63a5<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u8bbf\u95ee\uff1awss:\/\/xxxx.com\/wss<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">location \/wss { proxy_pass&nbsp;<a href=\"http:\/\/im.taoshangapp.com:9501;\/#%E4%BB%A3%E7%90%86%E5%88%B0%E4%B8%8A%E9%9D%A2%E7%9A%84%E5%9C%B0%E5%9D%80%E5%8E%BB%EF%BC%8C\">http:\/\/im.taoshangapp.com:9501;#\u4ee3\u7406\u5230\u4e0a\u9762\u7684\u5730\u5740\u53bb\uff0c<\/a>&nbsp;proxy_http_version 1.1; proxy_set_header Upgrade&nbsp;httpupgrade;proxysetheaderConnection&#8221;Upgrade&#8221;;proxysetheaderX\u2212real\u2212ip\u210e\ud835\udc61\ud835\udc61\ud835\udc5d\ud835\udc62\ud835\udc5d\ud835\udc54\ud835\udc5f\ud835\udc4e\ud835\udc51\ud835\udc52;\ud835\udc5d\ud835\udc5f\ud835\udc5c\ud835\udc65\ud835\udc66\ud835\udc60\ud835\udc52\ud835\udc61\u210e\ud835\udc52\ud835\udc4e\ud835\udc51\ud835\udc52\ud835\udc5f\ud835\udc36\ud835\udc5c\ud835\udc5b\ud835\udc5b\ud835\udc52\ud835\udc50\ud835\udc61\ud835\udc56\ud835\udc5c\ud835\udc5b&#8221;\ud835\udc48\ud835\udc5d\ud835\udc54\ud835\udc5f\ud835\udc4e\ud835\udc51\ud835\udc52&#8221;;\ud835\udc5d\ud835\udc5f\ud835\udc5c\ud835\udc65\ud835\udc66\ud835\udc60\ud835\udc52\ud835\udc61\u210e\ud835\udc52\ud835\udc4e\ud835\udc51\ud835\udc52\ud835\udc5f\ud835\udc4b\u2212\ud835\udc5f\ud835\udc52\ud835\udc4e\ud835\udc59\u2212\ud835\udc56\ud835\udc5dremote_addr; proxy_set_header X-Forwarded-For $remote_addr; }<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/gitee.com\/wmainng\/doc\/blob\/master\/Soft\/Websocket.md#workerman\"><\/a>workerman<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Swoole \u4f7f PHP \u5f00\u53d1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.bengbu.host\/index.php?rest_route=\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bengbu.host\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bengbu.host\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bengbu.host\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bengbu.host\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":1,"href":"https:\/\/www.bengbu.host\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":18,"href":"https:\/\/www.bengbu.host\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/18"}],"wp:attachment":[{"href":"https:\/\/www.bengbu.host\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bengbu.host\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bengbu.host\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}