PHP GD 捆绑扩展无需重新编译PHP - 解决方案
PHP GD bundled extension without recompiling PHP - solution
捆绑的扩展提供了很多功能。我花了很多时间如何为我的 PHP 版本编译扩展。所以有说明。
0, 安装 PHP 开发包。此外,您应该已经安装了带有 GD 扩展名的 PHP(但未捆绑)
sudo apt-get install php5-dev
1,下载使用过的源代码PHP(我是5.6.18)
wget http://cz2.php.net/get/php-5.6.18.tar.gz/from/this/mirror -O php-5.6.18.tar.gz
2, 提取存档
tar -xzf php-5.6.18.tar.gz
3,进入GD扩展源码
cd php-5.6.18/ext/gd/
4,准备扩展(运行phpize在那个目录)
phpize
5, 现在配置命令
5.1, 参数取决于您的 linux 分布。我的是这些:
--with-freetype-dir=shared,/usr --with-vpx-dir=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6
5.2, 用于获取库的路径您必须 运行 此命令并仅搜索上面指定的搜索参数 (5.1)
php-config --configure-options
5.3, 还要为配置添加这个参数(第二个参数是捆绑版本)
--with-php-config=/usr/bin/php-config --with-gd
6,最终配置命令
sudo ./configure --with-php-config=/usr/bin/php-config --with-gd --with-freetype-dir=YOUR_VALUE --with-vpx-dir=YOUR_VALUE --with-jpeg-dir=YOUR_VALUE --with-xpm-dir=YOUR_VALUE
7,现在运行制作
make
8, 编译后你应该看到这样的东西:
Libraries have been installed in:
/home/jakub/php-5.6.18/ext/gd/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
因此在目录 modules 中您已经编译了捆绑扩展 gd.so。
9,将 NOT bundled gd.so 替换为您新编译的捆绑扩展,对于我的 PHP 版本,它是命令:
sudo cp -f ./gd.so /usr/lib/php5/20131226/gd.so
10, 重启 Apache
sudo service apache2 restart
希望这对您有所帮助!您会不会比我花的时间少。
另一种方式:
- 转到 rpmfind.net 并搜索 php-gd-bundled for you php 版本。
- 提取 rpm (rpm2cpio archive_name.rpm | cpio -idmv)
- 备份您的 gd.so,然后将 gd.so 从存档复制到您的 php lib 目录。
我也可以使用以下参数编译模块:
#! /bin/sh
#
# Created by configure
'./configure' \
'--with-php-config=/usr/bin/php-config' \
'--with-gd=shared' \
'--with-freetype-dir=/usr' \
'--with-vpx-dir=/usr' \
'--with-jpeg-dir=/usr' \
'--with-xpm-dir=/usr' \
'--with-png-dir=/usr' \
'--with-t1lib=/usr' \
'--enable-gd-native-ttf' \
"$@"
捆绑的扩展提供了很多功能。我花了很多时间如何为我的 PHP 版本编译扩展。所以有说明。
0, 安装 PHP 开发包。此外,您应该已经安装了带有 GD 扩展名的 PHP(但未捆绑)
sudo apt-get install php5-dev
1,下载使用过的源代码PHP(我是5.6.18)
wget http://cz2.php.net/get/php-5.6.18.tar.gz/from/this/mirror -O php-5.6.18.tar.gz
2, 提取存档
tar -xzf php-5.6.18.tar.gz
3,进入GD扩展源码
cd php-5.6.18/ext/gd/
4,准备扩展(运行phpize在那个目录)
phpize
5, 现在配置命令
5.1, 参数取决于您的 linux 分布。我的是这些:
--with-freetype-dir=shared,/usr --with-vpx-dir=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6
5.2, 用于获取库的路径您必须 运行 此命令并仅搜索上面指定的搜索参数 (5.1)
php-config --configure-options
5.3, 还要为配置添加这个参数(第二个参数是捆绑版本)
--with-php-config=/usr/bin/php-config --with-gd
6,最终配置命令
sudo ./configure --with-php-config=/usr/bin/php-config --with-gd --with-freetype-dir=YOUR_VALUE --with-vpx-dir=YOUR_VALUE --with-jpeg-dir=YOUR_VALUE --with-xpm-dir=YOUR_VALUE
7,现在运行制作
make
8, 编译后你应该看到这样的东西:
Libraries have been installed in:
/home/jakub/php-5.6.18/ext/gd/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
因此在目录 modules 中您已经编译了捆绑扩展 gd.so。 9,将 NOT bundled gd.so 替换为您新编译的捆绑扩展,对于我的 PHP 版本,它是命令:
sudo cp -f ./gd.so /usr/lib/php5/20131226/gd.so
10, 重启 Apache
sudo service apache2 restart
希望这对您有所帮助!您会不会比我花的时间少。
另一种方式:
- 转到 rpmfind.net 并搜索 php-gd-bundled for you php 版本。
- 提取 rpm (rpm2cpio archive_name.rpm | cpio -idmv)
- 备份您的 gd.so,然后将 gd.so 从存档复制到您的 php lib 目录。
我也可以使用以下参数编译模块:
#! /bin/sh
#
# Created by configure
'./configure' \
'--with-php-config=/usr/bin/php-config' \
'--with-gd=shared' \
'--with-freetype-dir=/usr' \
'--with-vpx-dir=/usr' \
'--with-jpeg-dir=/usr' \
'--with-xpm-dir=/usr' \
'--with-png-dir=/usr' \
'--with-t1lib=/usr' \
'--enable-gd-native-ttf' \
"$@"