您的位置:首页 > 编程语言 > PHP开发

如何编译安装一个php模块

2012-07-23 15:02 423 查看
不止一次需要这么做了。

如果你需要的扩展在yum/apt仓库中没有的话,那需要自己编译了。
1. 下载PHP5.2.9的源代码(根据你php的版本选择)
2. 编译模块
进入对应模块的源码目录,然后:phpize、configure、make
$tar zxvf tar zxvf php-5.2.9.tar.gz $cd php-5.2.9/ext/curl $phpize   Configuring for:   PHP Api Version:         20041225   Zend Module Api No:      20060613   Zend Extension Api No:   220060519 $./configure --with-php-config=/opt/php/bin/php-config   checking for egrep... grep -E   checking for a sed that does not truncate output... /bin/sed   ......   configure: creating ./config.status   config.status: creating config.h $make   ......   Build complete.   Don't forget to run 'make test'.

3.将扩展文件(.so)cp到php的扩展目录
扩展目录的位置可以通过phpinfo的输出结果看到,也可以在php.ini文件中看到。
例如:
cp modules/sockets.so /home/admin/php/ext/
然后编辑php.ini文件
; extension_dir directive above.

extension_dir = "/home/admin/php/ext/"

extension=memcache.so

extension=curl.so

extension=rrdtool.so

extension=oci8.so

extension=sockets.so
4. 重启你的apache,Job done
可以通过phpinfo()来的输出来查看是否成功安装对应的模块。
参考:Compiling shared PECL extensions with phpize
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: