用 phpize 编译共享 PECL 扩展库

有时候不能用 pear 安装命令。这可能是因为在防火墙后面,或者是因为想要安装的扩展库还没有 PEAR 兼容的包,例如 CVS 中尚未发布的扩展库。如果要编译这种扩展库,可以用更底层的编译工具来手工进行编译。

phpize 命令是用来准备 PHP 扩展库的编译环境的。下面例子中,扩展库的源程序位于 extname 目录中:

$ cd extname
$ phpize
$ ./configure
$ make
# make install

成功的安装将创建 extname.so 并放置于 PHP 的扩展库目录中。需要调整 php.ini,加入 extension=extname.so 这一行之后才能使用此扩展库。


add a note add a note User Contributed Notes
dmytton at php dot net
04-Dec-2005 03:45
In some situations (e.g. on a cPanel server), the built extension will not be placed into the correct extensions directory by the make install process. Use your phpinfo() output to determine what the correct extension_dir path is and move the generated .so file into that directory. The extension=extname.so line in php.ini will then find the extension file correctly.