「零基础学easyswoole-2」php安装swoole扩展

一、环境要求

  • 保证 PHP 版本大于等于 7.1
  • 保证 Swoole 拓展版本大于等于 4.4.15
  • 需要 pcntl 拓展的任意版本
  • 使用 Linux / FreeBSD / MacOS 这三类操作系统
  • 使用 Composer 作为依赖管理工具
  • 使用 Ubuntu14 / CentOS 7.0 或更高版本操作系统

二、安装PHP-7.3.0

三、安装swoole

[root@localhost src]# cd /usr/local/src/
[root@localhost src]# wget https://github.com/swoole/swoole-src/archive/v4.4.16.tar.gz
[root@localhost src]# tar -zvxf v4.4.16.tar.gz
[root@localhost src]# cd swoole-src-4.4.16/
[root@localhost swoole-src-4.4.16]# phpize
[root@localhost swoole-src-4.4.16]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-openssl
[root@localhost swoole-src-4.4.16]# make && make install

四、查看自己的php.ini位置

[root@localhost swoole-src-4.4.16]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => /usr/local/php/etc/php.ini

五、配置php.ini

extension=swoole.so

六、通过php --ri swoole 查看是否安装成功

[root@localhost swoole-src-4.4.16]# php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.4.16
Built => Aug 26 2020 03:33:53
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2k-fips  26 Jan 2017
pcre => enabled
zlib => 1.2.7
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608

六、注意

  • 提示swoole.so.so类似的报错: 说明你的phpize版本和php-config设定的版本不一致,请重新编译

  • 安装成功 php --ri没有swoole: 说明你的php命令行版本,和安装swoole的php版本不一致,可以通过:php路径/bin/php --ri swoole 进行确认是否安装成功

猜你喜欢

转载自blog.csdn.net/weixin_41635750/article/details/108131932