phpize--扩展编译工具

Compiling shared PECL extensions with phpize

Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from SVN. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.

The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:

$ cd extname  进入到源码包中的扩展目录,这个扩展目录,通俗理解,若是要安装操做gd库,那么下载到这个库的源码后,解压源码会有个一个目录,进入这个目录。
$ phpize  运行phpize。路径不必定在这个目录下,但通常是在安装目录下(按照我理解,每一个phpize与具体的版本有关,不可能通用),去寻找phpize运行。以后会生成了一个configure文件
$ ./configure     运行。    若是生成基于数据库的扩展,须要加上参数运行:1,--with-php-config。2,"--with-具体的数据库参数".好比, --with-pgsql、--with-mysql
$ make
# make install 将会生成一个extname.so的扩展,被放到了PHP extensions directoryphp

 


A successful install will have created extname.so and put it into the PHP extensions directory(生成一个.so文件,自动放到php的扩展目录下去,我以为应该是phpize可以自动侦测到php扩展目录的位置).mysql

You'll need to and adjust php.ini and add an extension=extname.so line before you can use the extension.

If the system is missing the phpize command, and precompiled packages (like RPM's) are used, be sure to also install the appropriate devel version of the PHP package as they often include the phpize command along with the appropriate header files to build PHP and its extensions.

Execute phpize --help to display additional usage information.


phpize的做用能够这样理解:侦测环境(phpize工具是在php安装目录下,基于这点phpize对应了当时的php环境,因此是要根据该php的配置状况生成对应的configure文件),创建一个configure文件。必须在一个目录下去运行phpize。那么phpize就知道你的的环境是哪一个目录,而且configure文件创建在该目录下。sql

步骤总结:数据库

1、cd /usr/src/php源码包目录/ext/扩展目录/  

2、/usr/local/php5314/bin/phpize


3、./configure --with-php-config=/usr/local/php5314/bin/php-config

4、make && make install服务器

 

ps:make install会自动将生成的.so扩展复制到php的扩展目录下去,好比会提示已经安装到 /usr/local/php/php-5.5.18/lib/php/extensions/no-debug-non-zts-20121212/目录下去
5、剩下是配置php.iniapp

 




假如你的服务器上安装了多个版本php,那么须要告诉phpize要创建基于哪一个版本的扩展。经过使用--with-php-config=指定你使用哪一个php版本。

好比:--with-php-config=/usr/local/php524/bin/php-config  

关于php-config文件:是在php编译生成后(安装好),放在安装目录下的一个文件。打开phpize文件内容会发现,里面定义好了php的安装目录等变量工具

prefix='/usr/local/php'ui

phpize是编译安装时候生成好的,记录了当时安装的一些信息。并不能从其余地方拿个phpize来使用。spa

 phpize是在php安装目录下的一个文件。好比我安装了两个php5.2 和php5.3那么使用phpize也要使用对应版本的phpize才行。此时使用--with-php-config有什么做用?debug

 

phpize工具通常在哪里?

当php编译完成后,php安装目录下的bin目录下会有phpize这个脚本文件。因此是去安装好的php安装目录去找。

相关文章
相关标签/搜索