phpize,实际上只是一个脚本,用于准备PHP扩展的编译环境。
phpize [options]
命令行选项及含义
–clean
移除所有创建的文件。
–help
Prints usage information
–version / -v
Prints API version information
使用phpize安装扩展
系统环境:CentOS release 6.5 (Final)
PHP版本:PHP 5.6.15
PHP安装路径:/usr/local/php
示例扩展:这里以XHProf为例子
到pecl.php.net下载扩展
搜索,下载XHProf:http://pecl.php.net/get/xhprof-0.9.4.tgz
加压、进入源码目录、执行phpize命令,进行初始化
#!/bin/sh tar -xf xhprof-0.9.4.tgz cd xhprof-0.9.4 # 关键使找到config.m4文件所在的目录 cd ./extension /usr/local/php/bin/phpize # 因为PHP安装的/usr/local/php中,不符合FHS的标准,所以需要指出php-config的位置 ./configure \ --with-php-config=/usr/local/php/bin/php-config make && make install # make install会输出扩展最终的安装位置。
接下来就是修改php.ini文件,启动XHProf扩展。
Error List
#1 configure: error: Cannot find php-config. Please use –with-php-config=PATH
原因:configure的时候需要用到php-config命令,而php-config命令不在环境变量中。
解决:指定php-config文件的路径,如下所示
#!/bin/sh ./configure \ --with-php-config=/usr/local/php/bin/php-config