centos php pecl 安装的方法

  • 来源:网络
  • 更新日期:2020-09-21

摘要:centos php pecl安装的方法:首先更新yum源,安装php7;然后通过“$ yum install php-pear”命令安装PECL;最后配置“php.ini”即可。推荐:《centos入门教程》《PHP视频教程》 cento

centos php pecl安装的方法:首先更新yum源,安装php7;然后通过“$ yum install php-pear”命令安装PECL;最后配置“php.ini”即可。

推荐:《centos入门教程》《PHP视频教程》

centos 安装pecl

一、更新yum源,安装php7

CentOS/RHEL 7.x:

1 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2 rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

yum安装php7.0:(拓展自选)

 yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-memcached php70w-devel

以上命令安装了下面的拓展!

php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
二、安装PECL
//php版本 > 7
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar

//php版本 < 7
$ yum install php-pear
//否则会报错PHP Parse error:  syntax error, unexpected //'new' (T_NEW) in /usr/share/pear/PEAR/Frontend.php on //line 91
三、安装swoole
$ sudo pecl  install swoole
//报错如下//Warning: Invalid argument supplied for foreach() in //Command.php on line 249
vi `which pecl`
//找到最后一行
exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"

去掉 -n 标示

//报错如下
//running: phpize
//Can't find PHP headers in /usr/include/php

安装 PHP devel

成功!
//Build process completed successfully
//Installing '/usr/lib64/php/modules/swoole.so'
//install ok: channel://pecl.php.net/swoole-1.9.8
四、配置 php.ini
$ php -i | grep php.ini
//修改或者添加
 extension=swoole.so

五、卸载扩展

php.ini 中删除 extension=swoole.so

卸载,切换到PHP安装目录下的bin

./pecl uninstall swoole(已swoole为例)