一、下載PHP源碼包 http://php.net/get/php-7.2.4....php
tar -zxvf php-7.2.4.tar.gz cd php-7.2.4 ./configure --prefix=/usr/local/php make && make install
二、下載swoole源碼包git
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則安裝成功github
三、安裝redis https://redis.io/downloadredis
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
四、安裝hiredis(用於對異步Redis客戶端的支持) https://github.com/redis/hire...bash
make && make install ldconfig
五、從新編譯swooleswoole
./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異步
解決方案:async
vi ~/.bash_profile
在最後一行添加
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libspa
source ~/.bash_profile
六、安裝同步php-redis擴展.net
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則安裝成功