2023-05-12 开启多语言插件支持……

php扩展模块安装 快速自动安装

php 苏 demo 2292℃ 0评论
php开发简单,速度快,以及扩展灵活,在最近一些年,越来越得到广泛应用。 以前说到安装php模块,走过很多弯路。听人说可以用:rpm包,也可以用源码安装。
这些对于linux 初学者有时候真是一头雾水。 其实,安装扩展模块并没有想象那么复杂,而且只要我们用php 自带的模块安装命令就可以很好的完成。 下面我说说,
下载,编译,安装一步到位的方法。
1。安装php 模块安装命令。
wget http://pear.php.net/go-pear
php go_pear

代码[root@localhost ~]# php go-pear
Welcome to go-pear!

Go-pear will install the ‘pear’ command and all the files needed by
it. This command is your tool for PEAR installation and maintenance.

Go-pear also lets you download and install the following optional PEAR
packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.
If you wish to abort, press Control-C now, or press Enter to continue:

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

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 prefix ($prefix) : /root
2. Temporary files directory : $prefix/temp
3. Binaries directory : $prefix/bin
4. PHP code directory ($php_dir) : $prefix/PEAR
5. Documentation base directory : $php_dir/docs
6. Data base directory : $php_dir/data
7. Tests base directory : $php_dir/tests
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。
更详细的介绍可参考:http://www.shenmeshi.com/Computer/Computer_20071116151514.html

另外一种是用c或者c++编写外部模块加载至php中。
Pecl(The PHP Extension Community Library)就是干这个事的,PHP的标准扩展,可以补充实际开发中所需的功能。
所有的扩展都需要安装,在Windows下面以DLL的形式出现;在 linux下面需要单独进行编译,
它的表现形式为根据PHP官方的标准用C语言写成,尽管源码开放但是一般人无法随意更改源码。
其主页是 pecl.php.net。  最直接的表述:Pear是PHP的上层扩展,Pecl是PHP的底层扩展。
这两种方法其实都是为特定的应用提供现成的函数或者类,本质上来说都是一样的。
1
知道上面 2个区别,对于我们安装很方便理解了。我们一般so文件扩展,需要运行:pecl

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

代码[root@localhost ~]# pecl search http
Retrieving data…0%
Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest) Local
pecl_http 1.7.0 (stable) Extended HTTP Support
You have new mail in /var/spool/mail/root
[root@localhost ~]# pecl install pecl_http
downloading pecl_http-1.7.0.tgz …
Starting to download pecl_http-1.7.0.tgz (173,979 bytes)
……………………………….done: 173,979 bytes
source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
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  查看下。

[root@localhost ~]# php -m
[PHP Modules]
bz2
calendar
ctype
curl
date
dbase
dom
eAccelerator
exif
filter
ftp
gd
gettext
gmp
hash
http
。。。。。。。。。。。。。
已经安装成功。

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

 

 

 

 

 

 

 

 

 

打赏

转载请注明:苏demo的别样人生 » php扩展模块安装 快速自动安装

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)