您现在的位置是:首页 > 博客日记 > Php Php

安装pecl以及使用安装swoole

2019-06-27 17:04:27 【Php】 人已围观

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

  1. # cd /usr/local/php/bin/ //可查看是否已带有pecl
  2. # wget http://pear.php.net/go-pear.phar -O go-pear.php
  3. # ./php go-pear.php
  1. Below is a suggested file layout for your new PEAR installation. To
  2. change individual locations, type the number in front of the
  3. directory. Type 'all' to change all of them or simply press Enter to
  4. accept these locations.
  5. 1. Installation base ($prefix) : /usr/local/webserver/php
  6. 2. Temporary directory for processing : /tmp/pear/install
  7. 3. Temporary directory for downloads : /tmp/pear/install
  8. 4. Binaries directory : /usr/local/webserver/php/bin
  9. 5. PHP code directory ($php_dir) : /usr/local/webserver/php/share/pear
  10. 6. Documentation directory : /usr/local/webserver/php/docs
  11. 7. Data directory : /usr/local/webserver/php/data
  12. 8. User-modifiable configuration files directory : /usr/local/webserver/php/cfg
  13. 9. Public Web Files directory : /usr/local/webserver/php/www
  14. 10. System manual pages directory : /usr/local/webserver/php/man
  15. 11. Tests directory : /usr/local/webserver/php/tests
  16. 12. Name of configuration file : /usr/local/webserver/php/etc/pear.conf
  17. 1-12, 'all' or Enter to continue: all
  18. Installation base ($prefix) [/usr/local/webserver/php] :
  19. Temporary directory for processing [/tmp/pear/install] :
  20. Temporary directory for downloads [/tmp/pear/install] :
  21. Binaries directory [$prefix/bin] :
  22. PHP code directory ($php_dir) [$prefix/share/pear] :
  23. Documentation directory [$prefix/docs] :
  24. Data directory [$prefix/data] :
  25. User-modifiable configuration files directory [$prefix/cfg] :
  26. Public Web Files directory [$prefix/www] :
  27. System manual pages directory [$prefix/man] :
  28. Tests directory [$prefix/tests] :
  29. Name of configuration file [/usr/local/webserver/php/etc/pear.conf] :
  30. Below is a suggested file layout for your new PEAR installation. To
  31. change individual locations, type the number in front of the
  32. directory. Type 'all' to change all of them or simply press Enter to
  33. accept these locations.
  34. 1. Installation base ($prefix) : /usr/local/webserver/php
  35. 2. Temporary directory for processing : /tmp/pear/install
  36. 3. Temporary directory for downloads : /tmp/pear/install
  37. 4. Binaries directory : /usr/local/webserver/php/bin
  38. 5. PHP code directory ($php_dir) : /usr/local/webserver/php/share/pear
  39. 6. Documentation directory : /usr/local/webserver/php/docs
  40. 7. Data directory : /usr/local/webserver/php/data
  41. 8. User-modifiable configuration files directory : /usr/local/webserver/php/cfg
  42. 9. Public Web Files directory : /usr/local/webserver/php/www
  43. 10. System manual pages directory : /usr/local/webserver/php/man
  44. 11. Tests directory : /usr/local/webserver/php/tests
  45. 12. Name of configuration file : /usr/local/webserver/php/etc/pear.conf
  46. 1-12, 'all' or Enter to continue:
  47. Beginning install...
  48. Configuration written to /usr/local/webserver/php/etc/pear.conf...
  49. Initialized registry...
  50. Preparing to install...
  51. installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/Archive_Tar-1.4.7.tar...
  52. installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/Console_Getopt-1.4.2.tar...
  53. installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/PEAR-1.10.9.tar...
  54. installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/Structures_Graph-1.1.1.tar...
  55. installing phar:///usr/local/webserver/php/bin/go-pear.php/PEAR/go-pear-tarballs/XML_Util-1.4.3.tar...
  56. install ok: channel://pear.php.net/Archive_Tar-1.4.7
  57. install ok: channel://pear.php.net/Console_Getopt-1.4.2
  58. install ok: channel://pear.php.net/Structures_Graph-1.1.1
  59. install ok: channel://pear.php.net/XML_Util-1.4.3
  60. install ok: channel://pear.php.net/PEAR-1.10.9
  61. PEAR: Optional feature webinstaller available (PEAR's web-based installer)
  62. PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
  63. PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
  64. PEAR: To install optional features use "pear install pear/PEAR#featurename"
  65. ******************************************************************************
  66. WARNING! The include_path defined in the currently used php.ini does not
  67. contain the PEAR PHP directory you just specified:
  68. </usr/local/webserver/php/share/pear>
  69. If the specified directory is also not in the include_path used by
  70. your scripts, you will have problems getting any PEAR packages working.
  71. Would you like to alter php.ini </usr/local/webserver/php/etc/php.ini>? [Y/n] : y
  72. php.ini </usr/local/webserver/php/etc/php.ini> include_path updated.
  73. Current include path : .:
  74. Configured directory : /usr/local/webserver/php/share/pear
  75. Currently used php.ini (guess) : /usr/local/webserver/php/etc/php.ini
  76. Press Enter to continue:
  77. ** 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
  78. The 'pear' command is now at your service at /usr/local/webserver/php/bin/pear
  79. ** The 'pear' command is not currently in your PATH, so you need to
  80. ** use '/usr/local/webserver/php/bin/pear' until you have added
  81. ** '/usr/local/webserver/php/bin' to your PATH environment variable.
  82. Run it without parameters to see the available actions, try 'pear list'
  83. to see what packages are installed, or 'pear help' for help.
  84. For more information about PEAR, see:
  85. http://pear.php.net/faq.php
  86. http://pear.php.net/manual/
  87. Thanks for using go-pear!

添加软链接

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

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

  1. # pecl search swoole // swoole为要查询扩展名(以swoole扩展为例)
  2. //查询结果:
  3. Retrieving data...0%
  4. .Matched packages, channel pecl.php.net:
  5. =======================================
  6. Package Stable/(Latest) Local
  7. swoole 1.9.23 (stable) Event-driven asynchronous and concurrent networking engine with high performance for PHP.
  8. swoole_serialize 0.1.1 (beta) the fastest and smallest serialize fucntion bound for php7

可以指定安装版本

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

3、安装配置扩展

  1. # pecl install swoole
  2. //输出结果:
  3. Build process completed successfully
  4. Installing '/usr/lib64/php/modules/swoole.so'
  5. install ok: channel://pecl.php.net/swoole-1.9.23
  6. configuration option "php_ini" is not set to php.ini location
  7. You should add "extension=swoole.so" to php.ini
  1. [root@iZ2ze6xlhwqnd6ia8g045tZ bin]# ls
  2. go-pear.php pear peardev pecl phar phar.phar php php-cgi php-config phpdbg phpize
  3. [root@iZ2ze6xlhwqnd6ia8g045tZ bin]# pecl search swoole
  4. -bash: pecl: command not found
  5. [root@iZ2ze6xlhwqnd6ia8g045tZ bin]# ./pecl search swoole
  6. WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
  7. Retrieving data...0%
  8. .Matched packages, channel pecl.php.net:
  9. =======================================
  10. Package Stable/(Latest) Local
  11. swoole 4.3.5 (stable) Event-driven asynchronous and concurrent networking engine with high performance for PHP.
  12. swoole_serialize 0.1.1 (beta) the fastest and smallest serialize fucntion bound for php7
  13. [root@iZ2ze6xlhwqnd6ia8g045tZ bin]# ./pecl install swoole
  14. WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
  15. downloading swoole-4.3.5.tgz ...
  16. Starting to download swoole-4.3.5.tgz (1,348,319 bytes)
  17. ..........................................................................................................................................................................................................................................................................done: 1,348,319 bytes
  18. 359 source files, building
  19. running: phpize
  20. Configuring for:
  21. PHP Api Version: 20160303
  22. Zend Module Api No: 20160303
  23. Zend Extension Api No: 320160303
  24. enable sockets supports? [no] :

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



关注TinyMeng博客,更多精彩分享,敬请期待!
 

很赞哦! ()