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 進入到源碼包中的擴展目錄 $ phpize 運行phpize。路徑不一定在當前目錄下,去尋找phpize運行。之後會生成了一個configure文件 $ ./configure 運行。 如果生成基於數據庫的擴展,需要加上參數運行:1,--with-php-config。2,"--with-具體的數據庫參數".比如, --with-pgsql、--with-mysql $ make # make install 將會生成一個extname.so的擴展,被放到了PHP extensions directory A successful install will have created extname.so and put it into the PHP extensions directory. 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安裝目錄下,所以是要根據該php的配置情況生成對應的configure文件),建立一個configure文件。必須在一個目錄下去運行phpize。那麼phpize就知道你的的環境是哪個目錄,並且configure文件建立在該目錄下。 步驟總結: 一、cd /usr/src/php源碼包目錄/ext/擴展目錄/ 二、/usr/local/php5314/bin/phpize 三、./configure --with-php-config=/usr/local/php5314/bin/php-config 注:xampp安裝的話默認用 ./configure --with-php-config=/opt/lampp/bin/php-config 四、make && make install 五、剩下是配置php.ini 假如你的服務器上安裝了多個版本php,那麼需要告訴phpize要建立基於哪個版本的擴展。通過使用--with-php-config=指定你使用哪個php版本。 比如:--with-php-config=/usr/local/php524/bin/php-config 關於php-config文件:是在php編譯生成後(安裝好),放在安裝目錄下的一個文件。 疑問:phpize是在php安裝目錄下的一個文件。比如我安裝了兩個php5.2 和php5.3那麼使用phpize也要使用對應版本的phpize才行吧,此時使用--with-php-config有什麼作用? phpize工具一般在哪裡? 當php編譯完成後,php安裝目錄下的bin目錄下會有phpize這個腳本文件。所以是去安裝好的php安裝目錄先去找