在 php 中编译 freetype 支持

在 php 中编译 freetype 支持

我无法在 php 中编译 freetype 支持...

我的配置命令是:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-bcmath 
--enable-zip --with-zlib --with-gd --with-jpeg-dir=/usr/lib --with-mysqli 
--enable-mbstring --with-pdo-mysql  --with-pgsql=/usr/lib/pgsql 
--with-freetype-dir=/usr/lib --enable-gd-native-ttf

并且它运行良好(没有抱怨任何事情),编译也成功,但最终没有启用 freetype 支持:

["GD Version"]=> string(27) "bundled (2.0.34 compatible)" 
["FreeType Support"]=> bool(false)
["T1Lib Support"]=> bool(false) 

/usr/lib 看起来是寻找 freetype 的正确位置:

# pwd
/usr/lib
# ll|grep -i freetype
lrwxrwxrwx   1 root root       21 Dec 10 13:35 libfreetype.so -> libfreetype.so.6.3.10
lrwxrwxrwx   1 root root       21 Dec 10 13:35 libfreetype.so.6 -> libfreetype.so.6.3.10
-rwxr-xr-x   1 root root   525448 Nov 16 17:55 libfreetype.so.6.3.10

操作系统是Centos Linux 5,php版本是5.2.17。

有什么提示吗?谢谢!

答案1

由于这个问题是关于编译PHP 支持 FreeType,但不支持安装它,我想添加到这一点,以防其他人(像我一样)遇到这个问题,并且需要编译一个没有作为包提供的 PHP 版本。

  1. 首先,你需要安装 FreeType 库,可以从以下网址下载并编译:http://freetype.org/download.html或者通过安装您的操作系统可用的软件包。
  2. 第一个问题是指定的路径--with-freetype-dir不正确。你想要包括目录,而不是freetype 的目录。在我的例子中(在 CentOS v6.7 上),该目录是/usr/include/freetype2。您可以通过运行找到它find / -name freetype2
  3. 现在该部分已排序,您可以./configure使用--with-freetype-dir上面确定的参数运行。对于这个问题,完整的命令将是./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-bcmath --enable-zip --with-zlib --with-gd --with-jpeg-dir=/usr/lib --with-mysqli --enable-mbstring --with-pdo-mysql --with-pgsql=/usr/lib/pgsql --with-freetype-dir=/usr/include/freetype2 --enable-gd-native-ttf
  4. 如果你之前已经编译过 PHP,则需要make clean先运行。配置已更改,因此所有要清除的对象都需要重新编译。
  5. 运行make然后make install编译PHP。
  6. php -i通过运行或查看 的输出来验证 FreeType 是否已安装phpinfo();。如果使用 Web 服务器,您可能需要重新启动它以使更改生效。

答案2

在 CentOS 上,您只需使用 yum 并执行安装即可。

首先,我会执行以下命令并查看给出的结果,然后发出 yum 命令来安装 php-gd:

rpm -qa | grep php
yum install php-gd

确保以 root 身份运行这些程序,以便您有安装权限

相关内容