PHP 8.3.4 Released!

将 PECL 扩展库静态编译入 PHP

可能需要将扩展库静态编译到 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 需要强制重新生成配置脚本,然后正常编译 PHP:


$ 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.68automake 1.4+。更高版本的 autoconf 也许能工作,但不被支持。

是否用 --enable-extname--with-extname 取决于扩展库。通常不需要外部库文件的扩展库使用 --enable。当然,在 buildconf 之后运行:


$ ./configure --help | grep extname

add a note

User Contributed Notes 1 note

up
6
anthon at piwik dot org
11 years ago
Some extensions cannot be statically linked (e.g., xdebug).
To Top