有些擴充套件無法靜態連結(例如,xdebug)。
有時可能需要將 PECL 擴充功能靜態建置到 PHP 執行檔中。要執行此操作,需要將擴充功能原始碼放置在 /path/to/php/src/dir/ext/ 目錄下,並且需要 PHP 建置系統重新產生其 configure 指令碼。
$ cd /path/to/php/src/dir/ext $ pecl download extname $ gzip -d < extname.tgz | tar -xvf - $ mv extname-x.x.x extname
這將產生以下目錄
/path/to/php/src/dir/ext/extname
從這裡開始,需要強制 PHP 重新建置 configure 指令碼,然後就可以像平常一樣建置它
$ cd /path/to/php/src/dir $ rm configure $ ./buildconf --force $ ./configure --help $ ./configure --with-extname --enable-someotherext --with-foobar $ make $ make install
注意:要執行 buildconf 指令碼,需要 autoconf
2.68
和 automake1.4+
。較新版本的 autoconf 可能可以運作,但不支援。
使用 --enable-extname 還是 --with-extname 取決於擴充功能。通常,不需要外部函式庫的擴充功能會使用 --enable。為了確定,請在 buildconf 之後執行以下指令
$ ./configure --help | grep extname