ubuntu/debian PHP编译问题处理

记一次在debian使用编译方式安装php,提示 config: freetype-config not found的问题,部署的PHP版本为 7.2.34,以下是编译参数

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-inline-optimization --enable-fpm --enable-soap --enable-pcntl --enable-xml --with-libxml-dir --with-xmlrpc --with-openssl --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir  --with-png-dir --with-freetype-dir --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --with-libmbfl --with-onig--enable-pdo --with-pdo-mysql     --with-zlib-dir --with-pdo-sqlite  --with-readline --enable-session --enable-shmop --enable-opcache --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support

搜索找到以下的说法:

这是由于在Ubuntu 19.04 中 apt-get 安装的 libfreetype6-dev 版本为 2.9.1-3

http://changelogs.ubuntu.com/changelogs/pool/main/f/freetype/freetype_2.9.1-3/changelog

在changelog 中写到:

The `freetype-config' script is no longer installed by default

(Closes: #871470, #886461). All packages depending on libfreetype6-dev

should use pkg-config to find the relevant CFLAGS and libraries.

freetype-config 被替代成 pkg-config ,新版本使用 pkg-config 管理 CFLAGS 和 库

解决方法一般都是apt install freetype 之类的,但其实没有用,因为freetype2.10版本已经没有 freetype-config文件。

在尝试改为pkg-config 编译后,正常通过了,但zabbix页面的图形和图片显示就会有问题......,一直打圈圈或者图片异常。

而PHP在 7.4 版本后才修复和这个问题,但没有测试过7.4的兼容性,所以换个思路,使用编译方式安装freetype-2.8版本,然后指定目录编译即可。

下载链接

https://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz

创建安装目录

mkdir /usr/local/freetype

tar -zxf freetype-2.8.tar.gz

cd freetype-2.8

./configure --prefix=/usr/local/freetype && make && make install

安装完成后,修改freetype的参数加上安装目录,再重新编译安装php即可

--with-freetype-dir=/usr/local/freetype

查看php加载的模块

php -m

你可能感兴趣的:(ubuntu/debian PHP编译问题处理)