6

1、下载PHP源码包 http://php.net/get/php-7.2.4....

tar -zxvf php-7.2.4.tar.gz
cd php-7.2.4
./configure --prefix=/usr/local/php
make && make install

2、下载swoole源码包

git clone https://gitee.com/swoole/swoole.git 
cd swoole
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

最后将extension=swoole添加到php.ini中,php -m查看扩展,出现swoole则安装成功

3、安装redis https://redis.io/download

tar -zxvf redis-4.0.9.tar.gz
mv redis-4.0.9 /usr/local/redis-4.0.9
cd /usr/local/redis-4.0.9
make

4、安装hiredis(用于对异步Redis客户端的支持) https://github.com/redis/hire...

make && make install
ldconfig

5、重新编译swoole

./configure --with-php-config=/usr/local/php/bin/php-config --enable-async-redis
make clean
make && make install

PS:使用php -m 命令检测安装的扩展时 可能会出现一下警告
PHP Warning: PHP Startup: Unable to load dynamic library 'swoole' (tried: /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole (/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/swoole: cannot open shared object file: No such file or directory), /usr/local/php/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

解决方案:

vi ~/.bash_profile

在最后一行添加
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
图片描述

source ~/.bash_profile

6、安装同步php-redis扩展

git clone https://github.com/phpredis/phpredis.git
cd phpredis
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

最后将extension=redis添加到php.ini中,php -m查看扩展,出现redis则安装成功


luxesky
41 声望1 粉丝