编译安装swoole 启用openssl支持,Mac,php7.4.6.已安装swoole的重新编译安装一次也可以。生成swoole.so之后覆盖之前的swoole.so就行。
一、首先要安装openssl,没有的可以百度一下安装openssl,执行如下命令如果有输出路径即可
Yanzhongxin:consul admin$ which openssl
/usr/bin/openssl
二、编译安装swoole
最初我的swoole版本是4.6.3,反复重新编译安装都失败了。
于是我重新下载了swoole4.6.4:
http://pecl.php.net/package/swoole
解压后进入目录
Yanzhongxin:swoole-4.6.4 admin$ /Applications/MxSrvs/bin/php/bin/phpize
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
Yanzhongxin:swoole-4.6.4 admin$ ./configure --enable-openssl --with-openssl-dir=/usr/local/opt/openssl --enable-http2 --with-php-config=/Applications/MxSrvs/bin/php/bin/php-config
……
Yanzhongxin:swoole-4.6.4 admin$ make
……
Yanzhongxin:swoole-4.6.4 admin$ make install
Installing shared extensions: /Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20190902/ Installing header files: /Applications/MxSrvs/bin/php/include/php/
上面注意一下:
1.openssl路径是/usr/bin/openssl
执行命令发现并找不到
Yanzhongxin:consul admin$ cd /usr/bin/openssl
bash: cd: /usr/bin/openssl: Not a directory
Yanzhongxin:consul admin$ cd /usr/local/opt/openssl
Yanzhongxin:openssl admin$ ls
AUTHORS INSTALL_RECEIPT.json NEWS bin lib
CHANGES LICENSE README include share
./configure –enable-openssl –with-openssl-dir=
/usr/local/opt/openssl
–enable-http2 –with-php-config=/Applications/MxSrvs/bin/php/bin/php-config
所以这里注意openssl-dir的路径地址
2.编译后swoole.so的存放位置为:
Installing shared extensions:
/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20190902
3.请确定php.ini配置中加了extension=swoole.so的配置的
可以参考如下配置
extension=/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20190902/swoole.so
swoole.use_shortname = 'Off'
也可以将swoole.so 复制到php的ext/目录下
php.ini配置即为extension=swoole.so
三、查看安装是否成功开启了openssl
Yanzhongxin:swoole-4.6.4 admin$ php --ri swoole
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.6.4
Built => Mar 28 2021 18:09:50
coroutine => enabled with boost asm context
kqueue => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1g 21 Apr 2020
dtls => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777225/D16777225
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 => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144
版权声明:本文为lschuangye原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。