>  기사  >  백엔드 개발  >  快速自动安装php扩展模块的方法

快速自动安装php扩展模块的方法

WBOY
WBOY원래의
2016-07-25 09:04:331317검색
  1. wget http://pear.php.net/go-pear

  2. php go_pear
  3. [root@localhost ~]# php go-pear

  4. Welcome to go-pear!
  5. Go-pear will install the 'pear' command and all the files needed by

  6. it. This command is your tool for PEAR installation and maintenance.
  7. Go-pear also lets you download and install the following optional PEAR

  8. packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.
  9. If you wish to abort, press Control-C now, or press Enter to continue:

  10. HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none::

  11. Below is a suggested file layout for your new PEAR installation. To

  12. change individual locations, type the number in front of the
  13. directory. Type 'all' to change all of them or simply press Enter to
  14. accept these locations.
  15. 1. Installation prefix ($prefix) : /root

  16. 2. Temporary files directory : $prefix/temp
  17. 3. Binaries directory : $prefix/bin
  18. 4. PHP code directory ($php_dir) : $prefix/PEAR
  19. 5. Documentation base directory : $php_dir/docs
  20. 6. Data base directory : $php_dir/data
  21. 7. Tests base directory : $php_dir/tests
  22. 1-7, 'all' or Enter to continue:

复制代码

可以选择:1 设置你安装路径。 接下来,一路回车就可以完成安装了。 现在,你可以直接运行:pecl pear 2个命令进行安装。

什么是:pear pecl 呢? Pear、Pecl都是PHP扩展模块的集合。 扩展PHP有两种方法: 一种是用纯粹的php代码写函数和类。   Pear就是这样一个项目。PEAR是PHP的官方开源类库(PHP Extension and Application Repository的缩写)。 Pear在英文中是梨子的意思。PEAR将PHP程序开发过程中常用的功能编写成类库,涵盖了页面呈面、数据库访问、文件操作、 数据结构、缓存操作、网络协议等许多方面,用户可以很方便地使用。它是一个PHP扩展及应用的一个代码仓库, 简单地说,PEAR就是PHP的 cpan。其主页是pear.php.net。   另外一种是用c或者c++编写外部模块加载至php中。   Pecl(The PHP Extension Community Library)就是干这个事的,PHP的标准扩展,可以补充实际开发中所需的功能。 所有的扩展都需要安装,在Windows下面以DLL的形式出现;在 linux下面需要单独进行编译, 它的表现形式为根据PHP官方的标准用C语言写成,尽管源码开放但是一般人无法随意更改源码。 其主页是 pecl.php.net。  最直接的表述:Pear是PHP的上层扩展,Pecl是PHP的底层扩展。   这两种方法其实都是为特定的应用提供现成的函数或者类,本质上来说都是一样的。

知道上面 2个区别,对于我们安装很方便理解了。我们一般so文件扩展,需要运行:pecl

2.下面,安装个:pecl_http扩展试下

  1. [root@localhost ~]# pecl search http
  2. Retrieving data...0%
  3. Matched packages, channel pecl.php.net:
  4. =======================================
  5. Package Stable/(Latest) Local
  6. pecl_http 1.7.0 (stable) Extended HTTP Support
  7. You have new mail in /var/spool/mail/root
  8. [root@localhost ~]# pecl install pecl_http
  9. downloading pecl_http-1.7.0.tgz ...
  10. Starting to download pecl_http-1.7.0.tgz (173,979 bytes)
  11. .....................................done: 173,979 bytes
  12. 71 source files, building
  13. running: phpize
  14. Configuring for:
  15. PHP Api Version: 20041225
  16. Zend Module Api No: 20060613
  17. Zend Extension Api No: 220060519
  18. whether to enable cURL HTTP requests; specify libcurl directory [yes] :
复制代码

先运行:search 命令模糊搜索,然后可以用,pecl install pecl_http . 一路回车,一会儿 在: [root@localhost ~]# ll /usr/lib/php/modules/http.so -rw-r--r-- 1 root root 1274476 06-26 08:56 /usr/lib/php/modules/http.so 存在自己的模块了。(不同系统,位置可能不同),上一步安装完后,会告诉模块所在地址。

3.配制php.ini 加入: extension=http.so 就ok了。

然后,可以通过php -m 查看下。

  1. [root@localhost ~]# php -m
  2. [PHP Modules]
  3. bz2
  4. calendar
  5. ctype
  6. curl
  7. date
  8. dbase
  9. dom
  10. eAccelerator
  11. exif
  12. filter
  13. ftp
  14. gd
  15. gettext
  16. gmp
  17. hash
  18. http
复制代码

已经安装成功。 后记: 其它也有源码安装,上pecl.php.net 找到对应源码包解压。 可以通过:pecl install 源码文件。



성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.