phpize 编译个别 PHP 模组


当编译 PHP 之后, 发觉需要加入一些额外的模组, 在不重新编译 PHP 的情况下, 可以用 phpize 编译单一模组, 在 php.ini 加入模组的 .so 便可以。以下会以 GD 为例, 用 phpize 单独编译 GD 模组。

在编译 GD 模组前, 先用 YUM 安装 GD 所需的相关套件, 包括 freetype, libjpeg 及 libpng:

# yum install freetype libjpeg libpng

然后 CD 到 PHP 源始码目录, 编译 GD 模组, 以下会以 PHP 5.5.28 为例:

# cd /path/to/php-5.5.28
# cd ext/gd

给予 phpize 可执行权限, 及用 phpize 编译 GD 模组:

# chmod 755 ../../scripts/phpize
# ../../scripts/phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212

# ./configure –with-php-config=/usr/bin/php-config –with-jpeg –with-png -with-freetype
# make && make install

这时应该会编译产生一个 gd.so 的档案, 开启档案 php.ini, 加入以下一行:

extension=gd.so

储存盘案后重新启动 Apache.

Tags:

Leave a Reply