phpiredis异步redis
swoole 扩展
先安装php7.2
apt install php7.2-fpm php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-opcache -y
安装http2
wget https://github.com/nghttp2/nghttp2/releases/download/v1.30.0/nghttp2-1.30.0.tar.bz2
tar -jxvf nghttp2-1.30.0.tar.bz2
cd nghttp2-1.30.0/
./configure
make
make install
安装异步redis
git clone https://github.com/nrk/phpiredis.git
cd phpiredis/
/usr/bin/phpize7.2
./configure --enable-phpiredis
make
make install
sudo vim /etc/php/7.2/mods-available/phpiredis.ini添加extension=phpiredis.so
sudo ln -s /etc/php/7.2/mods-available/phpiredis.ini /etc/php/7.2/cli/conf.d/20-phpiredis.ini
sudo ln -s /etc/php/7.2/mods-available/phpiredis.ini /etc/php/7.2/fpm/conf.d/20-phpiredis.ini
重启php
安装swoole
wget https://github.com/swoole/swoole-src/archive/v2.1.3.tar.gz
tar -zxvf v2.1.3.tar.gz
cd swoole-src-2.1.3/
/usr/bin/phpize7.2
./configure --enable-async-redis --enable-mysqlnd --enable-coroutine --enable-openssl --enable-http2
make
make install
sudo vim /etc/php/7.2/mods-available/swoole.ini添加extension=swoole.so
sudo ln -s /etc/php/7.2/mods-available/swoole.ini /etc/php/7.2/cli/conf.d/20-swoole.ini
sudo ln -s /etc/php/7.2/mods-available/swoole.ini /etc/php/7.2/fpm/conf.d/20-swoole.ini
重启php
php -m | grep swoole
php --ri swoole
看到如下结果标识正确:
swoole
swoole support => enabled
Version => 2.1.3
Author => tianfeng.han[email: mikan.tenny@gmail.com]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async redis client => enabled
async http/websocket client => enabled
openssl => enabled
http2 => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608