安装pecl以及使用安装swoole

1、安装pecl及创建快捷键(若安装php时已带可忽略这步安装步骤)

# cd /usr/local/php/bin/  //可查看是否已带有pecl 
# wget http://pear.php.net/go-pear.phar -O go-pear.php 
# ./php go-pear.php 
Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr/local/webserver/php
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/webserver/php/bin
 5. PHP code directory ($php_dir)                 : /usr/local/webserver/php/share/pear
 6. Documentation directory                       : /usr/local/webserver/php/docs
 7. Data directory                                : /usr/local/webserver/php/data
 8. User-modifiable configuration files directory : /usr/local/webserver/php/cfg
 9. Public Web Files directory                    : /usr/local/webserver/php/www
10. System manual pages directory                 : /usr/local/webserver/php/man
11. Tests directory                               : /usr/local/webserver/php/tests
12. Name of configuration file                    : /usr/local/webserver/php/etc/pear.conf

1-12, 'all' or Enter to continue: all
Installation base ($prefix) [/usr/local/webserver/php] : 
Temporary directory for processing [/tmp/pear/install] : 
Temporary directory for downloads [/tmp/pear/install] : 
Binaries directory [$prefix/bin] : 
PHP code directory ($php_dir) [$prefix/share/pear] : 
Documentation directory [$prefix/docs] : 
Data directory [$prefix/data] : 
User-modifiable configuration files directory [$prefix/cfg] : 
Public Web Files directory [$prefix/www] : 
System manual pages directory [$prefix/man] : 
Tests directory [$prefix/tests] : 
Name of configuration file [/usr/local/webserver/php/etc/pear.conf] : 

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr/local/webserver/php
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/webserver/php/bin
 5. PHP code directory ($php_dir)                 : /usr/local/webserver/php/share/pear
 6. Documentation directory                       : /usr/local/webserver/php/docs
 7. Data directory                                : /usr/local/webserver/php/data
 8. User-modifiable configuration files directory : /usr/local/webserver/php/cfg
 9. Public Web Files directory                    : /usr/local/webserver/php/www
10. System manual pages directory                 : /usr/local/webserver/php/man
11. Tests directory                               : /usr/local/webserver/php/tests
12. Name of configuration file                    : /usr/local/webserver/php/etc/pear.conf

1-12, 'all' or Enter to continue: 
Beginning install...
Configuration written to /usr/local/webserver/php/etc/pear.conf...
Initialized registry...
Preparing to install...
installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/Archive_Tar-1.4.7.tar...
installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/Console_Getopt-1.4.2.tar...
installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/PEAR-1.10.9.tar...
installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/Structures_Graph-1.1.1.tar...
installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/XML_Util-1.4.3.tar...
install ok: channel://pear.php.net/Archive_Tar-1.4.7
install ok: channel://pear.php.net/Console_Getopt-1.4.2
install ok: channel://pear.php.net/Structures_Graph-1.1.1
install ok: channel://pear.php.net/XML_Util-1.4.3
install ok: channel://pear.php.net/PEAR-1.10.9
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

******************************************************************************
WARNING!  The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
</usr/local/webserver/php/share/pear>
If the specified directory is also not in the include_path used by
your scripts, you will have problems getting any PEAR packages working.


Would you like to alter php.ini </usr/local/webserver/php/etc/php.ini>? [Y/n] : y

php.ini </usr/local/webserver/php/etc/php.ini> include_path updated.

Current include path           : .:
Configured directory           : /usr/local/webserver/php/share/pear
Currently used php.ini (guess) : /usr/local/webserver/php/etc/php.ini
Press Enter to continue: 

** WARNING! Old version found at /usr/local/webserver/php/bin, please remove it or be sure to use the new /usr/local/webserver/php/bin/pear command

The 'pear' command is now at your service at /usr/local/webserver/php/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/local/webserver/php/bin/pear' until you have added
** '/usr/local/webserver/php/bin' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

  http://pear.php.net/faq.php
  http://pear.php.net/manual/

Thanks for using go-pear!

添加软链接

# ln -s /usr/local/php /usr/bin/pecl

2、查询是否已经收录了该扩展

# pecl search swoole  // swoole为要查询扩展名(以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

可以指定安装版本

通过搜索进入扩展包页面 https://pecl.php.net/package/swoole
找到需要安装的版本 swoole-1.9.23.tgz (https://pecl.php.net/get/swoole-1.9.23.tgz)

3、安装配置扩展

# pecl install swoole 
//输出结果: 
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 
[root@iZ2ze6xlhwqnd6ia8g045tZ bin]# ls
go-pear.php  pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpdbg  phpize
[root@iZ2ze6xlhwqnd6ia8g045tZ bin]# pecl search swoole 
-bash: pecl: command not found
[root@iZ2ze6xlhwqnd6ia8g045tZ bin]# ./pecl search swoole 
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
Retrieving data...0%
.Matched packages, channel pecl.php.net:
=======================================
Package          Stable/(Latest) Local
swoole           4.3.5 (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
[root@iZ2ze6xlhwqnd6ia8g045tZ bin]# ./pecl install swoole
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading swoole-4.3.5.tgz ...
Starting to download swoole-4.3.5.tgz (1,348,319 bytes)
..........................................................................................................................................................................................................................................................................done: 1,348,319 bytes
359 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
enable sockets supports? [no] : 

配置php.ini引用swoole.so然后重启php即可

Last modification:June 27th, 2019 at 05:07 pm
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment