1、安装pecl及创建快捷键(若安装PHP时已带可忽略这步安装步骤)
PHP/bin/ //可查看是否已带有pecl
# wget http://pear.PHP.net/go-pear.phar -O go-pear.PHP
# PHP go-pear.PHP
# ln -s /usr/local/PHP
/bin/pecl /usr/bin/pecl
2、查询是否已经收录了该扩展
查询扩展名(以swoole扩展为例)
//查询结果:
Retrieving data...0%
.Matched packages,channel pecl.PHP.net:
=======================================
Package Stable/(Latest) Local
swoole 1.9.23 (stable) Event-driven asynchronous and concurrent networking engine with high performance for PHP.
swoole_serialize 0.1.1 (beta) the fastest and smallest serialize fucntion bound for PHP7
3、安装配置扩展
输出结果:
Build process completed successfully
Installing '/usr/lib64/PHP/modules/swoole.so'
install ok: channel://pecl.PHP.net/swoole-1.9.23
configuration option "PHP_ini" is not set to PHP.ini location
You should add "extension=swoole.so" to PHP.ini
配置PHP.ini引用swoole.so然后重启PHP即可
注:
相比于PHPize方式安装,pecl方式安装更为简便,可省去手动添加到PHP.ini的环节以上这篇PHP通过pecl方式安装扩展的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。
原文链接:https://www.f2er.com/php/16342.html