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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章