{"id":323,"title":"centos7.4 64\u4f4d\u4e0bswoole\u5b89\u88c5\u53ca\u914d\u7f6e","good":0,"bad":0,"hit":8213,"created_at":"2018-06-14 23:00:45","content":"
\u65b9\u6cd51\uff1a(\u81ea\u6d4b\u5b89\u88c5\u5931\u8d25\uff09
<\/p>
pecl install swoole<\/p>
<\/p>
\u65b9\u6cd52\uff1a\u3010\u6e90\u7801\u5b89\u88c5swoole\u3011\uff0c\u81ea\u6d4b\u5b89\u88c5\u6210\u529f<\/p>
<\/p>
\u5b89\u88c5\u5bf9\u5f02\u6b65redis\u7684\u652f\u6301\uff1a<\/p>
\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/wiki.swoole.com\/wiki\/page\/p-redis.html<\/p>
\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>
wget https:\/\/github.com\/redis\/hiredis\/archive\/v0.13.3.tar.gz<\/p>
tar -zxvf v0.13.3.tar.gz<\/p>
cd hiredis-0.13.3\/<\/p>
[root@localhost hiredis-0.13.3]make -j<\/p>
[root@localhost hiredis-0.13.3]sudo make install<\/p>
[root@localhost hiredis-0.13.3]sudo ldconfig<\/p>
<\/p>
\u5b89\u88c5\u9700\u8981\u7684\u5305\uff1a<\/p>
yum install glibc-headers <\/span><\/span><\/p><\/li> yum install gcc-c++ <\/span><\/p><\/li><\/ol> \u5b89\u88c5swoole:<\/p> www.swoole.com\u9996\u9875\u627e\u5230\u4e0b\u8f7d\uff1a<\/p> https:\/\/gitee.com\/swoole\/swoole\/tree\/v2.1.2<\/p> yum install git<\/p> git clone https:\/\/gitee.com\/swoole\/swoole.git<\/p> \u6216\u76f4\u63a5\u4e0b\u8f7dzip\u5305\u7136\u540eunzip<\/p> cd\u8fdb\u5165\u89e3\u538b\u540e\u7684\u76ee\u5f55<\/p> \u770b\u770b\u6709\u6ca1\u6709configure\u8fd9\u4e2a\u6587\u4ef6\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u5728\u89e3\u538b\u540e\u7684swoole\u76ee\u5f55\u4e2d\u6267\u884c\uff1a<\/p> \/php\u5b89\u88c5\u76ee\u5f55\/bin\/phpize<\/p> \u6267\u884c\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u770b\u5230\u751f\u6210\u7684configure\u6587\u4ef6\u4e86<\/p> .\/configure --help\u53ef\u4ee5\u770b\u5230\u5b89\u88c5\u65f6\u53ef\u4ee5\u6307\u5b9a\u7684\u76f8\u5173\u8bbe\u7f6e\u9879<\/p> \u5982\uff1a<\/p> --with-php-config=\/usr\/local\/bin\/php-config(\u6307\u5b9aphp\u914d\u7f6e\u6587\u4ef6\u8def\u5f84)<\/p> --enable-async-redis\uff08\u589e\u52a0\u5bf9\u5f02\u6b65redis\u7684\u652f\u6301)<\/p> --enable-coroutine(\u5f00\u542f\u534f\u7a0b)<\/p> [root@localhost swoole]# .\/configure --with-php-config=\/usr\/local\/bin\/php-config --enable-openssl --enable-async-redis --enable-mysqlnd<\/p> [root@localhost swoole]#make clean(\u5982\u679c\u4e4b\u524dmake\u8fc7\uff0c\u6267\u884c\u4e00\u4e0b\u6b21\u884c\u547d\u4ee4\uff09<\/p> [root@localhost swoole]#make<\/p> [root@localhost swoole]#make install\u540e\uff0c\u53ef\u4ee5\u770b\u5230\u5c4f\u5e55\u6253\u5370\u51fa\u751f\u6210\u7684\u6269\u5c55\u7684\u8def\u5f84<\/p> \u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\uff1a<\/p> php-m \u53d1\u73b0swoole\u6d88\u5931\u6216\u8005\u662f\u901a\u8fc7php --ri swoole\u6ca1\u6709\u663e\u793aasync redis client<\/p> \u6216\u62a5\u7c7b\u4f3c\u9519\u8bef\uff1a<\/p> PHP Warning: PHP Startup: Unable to load dynamic library 'swoole' (tried: \/usr\/local\/lib\/php\/extensions\/no-debug-non-zts-20170718\/swoole (\/usr\/local\/lib\/php\/extensions\/no-debug-non-zts-20170718\/swoole: cannot open shared object file: No such file or directory), \/usr\/local\/lib\/php\/extensions\/no-debug-non-zts-20170718\/swoole.so (libhiredis.so.0.13: cannot open shared object file: No such file or directory)) in Unknown on line 0<\/p> \u89e3\u51b3\u65b9\u6cd5\uff1a<\/p> vi ~\/.bash_profile<\/p> \u5728\u6700\u540e\u4e00\u884c\u6dfb\u52a0 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:\/usr\/local\/lib<\/p> source ~\/.bash_profile<\/p> \u91cd\u65b0\u7f16\u8bd1\u5b89\u88c5swoole\u5373\u53ef<\/p> \u68c0\u67e5\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p> php -m \u67e5\u770bswoole\u6269\u5c55\u662f\u5426\u5f00\u542f<\/p> php --ri swoole\u67e5\u770basync redis client => enabled\u662f\u5426\u5b58\u5728<\/p> \u3010\u8ba9php7\u652f\u6301swoole\u3011<\/p> \u5728php.ini\u4e2d\u6dfb\u52a0<\/p> extension=swoole<\/p> extension=sockets(\u5982\u679c\u62a5\u9519\u7684\u8bdd)<\/p> php -m \u67e5\u770b\u662f\u5426\u6709swoole\u6269\u5c55<\/p> \u5230\u4e4b\u524d\u4e0b\u8f7d\u7684swoole\u6e90\u7801\u4e2d\u7684examples\/server\u4e0b\u6267\u884c<\/p> php echo.php<\/p> \u5982\u679c\u4e0d\u62a5\u9519\u5c31\u5b89\u88c5\u6210\u529f\u4e86<\/p> netstat -ntlp\u770b\u770b<\/p> \u3010tcp\u4e0eudp\u7684\u533a\u522b\u3011<\/p> https:\/\/blog.csdn.net\/li_ning_\/article\/details\/52117463<\/p> \u3010\u67e5\u770b\u8fdb\u7a0b\u53ca\u72b6\u6001\u3011<\/p> ps aft | grep tcp.php(\u67d0\u4e2aserver\u6587\u4ef6\u7684\u540d\u79f0)<\/p> D \u4e0d\u53ef\u4e2d\u65ad Uninterruptible sleep (usually IO)<\/p> R \u6b63\u5728\u8fd0\u884c\uff0c\u6216\u5728\u961f\u5217\u4e2d\u7684\u8fdb\u7a0b<\/p> S \u5904\u4e8e\u4f11\u7720\u72b6\u6001<\/p> T \u505c\u6b62\u6216\u88ab\u8ffd\u8e2a<\/p> Z \u50f5\u5c38\u8fdb\u7a0b<\/p> W \u8fdb\u5165\u5185\u5b58\u4ea4\u6362\uff08\u4ece\u5185\u68382.6\u5f00\u59cb\u65e0\u6548\uff09<\/p> X \u6b7b\u6389\u7684\u8fdb\u7a0b<\/p> < \u9ad8\u4f18\u5148\u7ea7<\/p> N \u4f4e\u4f18\u5148\u7ea7<\/p> L \u6709\u4e9b\u9875\u88ab\u9501\u8fdb\u5185\u5b58<\/p> s \u5305\u542b\u5b50\u8fdb\u7a0b<\/p> + \u4f4d\u4e8e\u540e\u53f0\u7684\u8fdb\u7a0b\u7ec4<\/p> l \u591a\u7ebf\u7a0b\uff0c\u514b\u9686\u7ebf\u7a0b<\/p> \u3010nginx\u8f6c\u53d1\u3011<\/p> \u5c06root\u6307\u5411\u7684\u76ee\u5f55\u4e2d\u4e0d\u5b58\u5728\u7684\u8bf7\u6c42\u8f6c\u53d1<\/p> location \/ {<\/p> <\/span>root \/home\/....<\/p> <\/span>index index.html<\/p> <\/span>if \u8fd9\u91cc\u6709\u4e2a\u7a7a\u683c(!-e $request_filename){<\/p> <\/span> #\u4ee5\u4e0b\u662f\u4e00\u53f0\u673a\u5668\u65f6\u7684\u914d\u7f6e\u65b9\u6cd5<\/p> <\/span> proxy_pass http:\/\/ip:\u7aef\u53e3;<\/p> <\/span> #\u4ee5\u4e0b\u662f\u591a\u53f0\u673a\u5668\u65f6\u7684\u914d\u7f6e\u65b9\u6cd5<\/p> <\/span> proxy_pass http:\/\/swoole_hurong<\/p> <\/span>}<\/p> }<\/p> upstream swoole_hurong\u8fd9\u4e2a\u540d\u79f0\u968f\u4fbf\u8d77 {<\/p> <\/span>server ip:\u7aef\u53e3 weight=2;#\u7b49\u53f7\u4e24\u8fb9\u4e0d\u80fd\u6709\u7a7a\u683c<\/p> <\/span>server ip:\u7aef\u53e3 weight=1;<\/p> }<\/p> \u3010nginx\u8d1f\u8f7d\u5747\u8861\u3011<\/p> \u7b2c\u4e00\u53f0\u627f\u62c52\/3<\/p> \u7b2c\u4e8c\u53f0\u627f\u62c51\/3<\/p> upstream swoole_hurong\u8fd9\u4e2a\u540d\u79f0\u968f\u4fbf\u8d77 {<\/p> <\/span>server ip:\u7aef\u53e3 weight=2;#\u7b49\u53f7\u4e24\u8fb9\u4e0d\u80fd\u6709\u7a7a\u683c<\/p> <\/span>server ip:\u7aef\u53e3 weight=1;<\/p> }<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>"}