美文网首页我爱编程
brew升级swoole踩坑记

brew升级swoole踩坑记

作者: 小晨主 | 来源:发表于2018-05-24 20:16 被阅读0次

    问题描述及解决方法

    1. 当前php71是通过 brew install php@7.1 方式安装

    2. swoole扩展是通过之前brew install php71-swoole 方式安装

    3. 执行brew list 查看当前安装情况

      ➜  brew list
      php71-redis     
      php71-swoole        
      php@7.1
      ...
      
    4. 通过之前方式brew update php71-swoole更新扩展时会失败

    5. 通过brew uninstall php71-swoole先卸载掉swoole扩展,再编译安装

    6. 使用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
      
    7. 问题出在这里,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"
      
    8. 删除该配置文件

      ➜  rm -f /usr/local/etc/php/7.1/conf.d/ext-swoole.ini
      
    9. 重新安装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/
      
    10. 修改php.ini配置信息,添加swoole扩展

      extension=swoole.so
      
    11. 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)
      
    12. 查看swoole信息

      1. 通过phpinfo()查看swoole信息
      WX20180524-200715.png
      1. 或通过命令行方式查看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
      

    参考链接

    homebrewでphp71-*系がインストールできなくなってた

    swoole安装

    相关文章

      网友评论

        本文标题:brew升级swoole踩坑记

        本文链接:https://www.haomeiwen.com/subject/zkcejftx.html