捆绑扩展提供了许多功能。我花了很多时间来编译我的PHP版本的扩展。所以有说明。
答案 0 :(得分:11)
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,还为configure添加此参数(第二个参数生成捆绑版本)
--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
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'.
因此,在模块目录中,您已编译了捆绑的扩展名 gd.so 。 9,替换NOT捆绑的gd.so由你的新编译的捆绑扩展,对于我的PHP版本它是命令:
sudo cp -f ./gd.so /usr/lib/php5/20131226/gd.so
10,重启Apache
sudo service apache2 restart
希望这有帮助!并且你花的时间比我少。
答案 1 :(得分:0)
另一种方式:
我也可以使用以下参数编译模块:
#! /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' \
"$@"