brew升级swoole踩坑记
2018-05-24 本文已影响0人
小晨主
问题描述及解决方法
-
当前php71是通过
brew install php@7.1
方式安装 -
swoole扩展是通过之前
brew install php71-swoole
方式安装 -
执行
brew list
查看当前安装情况➜ brew list php71-redis php71-swoole php@7.1 ...
-
通过之前方式
brew update php71-swoole
更新扩展时会失败 -
通过
brew uninstall php71-swoole
先卸载掉swoole扩展,再编译安装 -
使用
php -m |grep swoole
查看swoole是否已删除掉➜ php -m | grep swoole PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php71-swoole/swoole.so' - dlopen(/usr/local/opt/php71-swoole/swoole.so, 9): image not found in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php71-swoole/swoole.so' - dlopen(/usr/local/opt/php71-swoole/swoole.so, 9): image not found in Unknown on line 0
-
问题出在这里,swoole扩展仍然被加载
➜ conf.d ll total 64 -rw-r--r-- 1 wangchen admin 62B 3 2 18:34 ext-gearman.ini -rw-r--r-- 1 wangchen admin 300B 3 2 18:34 ext-igbinary.ini -rw-r--r-- 1 wangchen admin 62B 3 19 13:07 ext-imagick.ini -rw-r--r-- 1 wangchen admin 62B 3 2 18:34 ext-mongodb.ini -rw-r--r-- 1 wangchen admin 62B 3 21 17:02 ext-msgpack.ini -rw-r--r-- 1 wangchen admin 78B 4 4 09:51 ext-opcache.ini -rw-r--r-- 1 wangchen admin 292B 3 2 18:35 ext-redis.ini -rw-r--r-- 1 wangchen admin 59B 3 5 17:59 ext-swoole.ini ➜ cat /usr/local/etc/php/7.1/conf.d/ext-swoole.ini [swoole] extension="/usr/local/opt/php71-swoole/swoole.so"
-
删除该配置文件
➜ rm -f /usr/local/etc/php/7.1/conf.d/ext-swoole.ini
-
重新安装swoole
➜ wget https://github.com/swoole/swoole-src/archive/v2.1.3.tar.gz ➜ tar zxcvf swoole-src-2.1.3.tar.gz ➜ cd swoole-src-2.1.3 ➜ phpize ➜ ./configure ➜ make ➜ sudo make install Installing shared extensions: /usr/local/Cellar/php@7.1/7.1.16/pecl/20160303/ Installing header files: /usr/local/Cellar/php@7.1/7.1.16/include/php/
-
修改php.ini配置信息,添加swoole扩展
extension=swoole.so
-
brew重启php@7.1
➜ ~ brew services restart php@7.1 Stopping `php@7.1`... (might take a while) ==> Successfully stopped `php@7.1` (label: homebrew.mxcl.php@7.1) ==> Successfully started `php@7.1` (label: homebrew.mxcl.php@7.1)
-
查看swoole信息
- 通过phpinfo()查看swoole信息
- 或通过命令行方式查看swoole信息
➜ ~ php --ri 'swoole' swoole swoole support => enabled Version => 2.1.3 Author => tianfeng.han[email: mikan.tenny@gmail.com] coroutine => enabled kqueue => enabled rwlock => enabled async http/websocket client => enabled pcre => enabled zlib => 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