Arch 編譯安裝 PHP 失敗

場(chǎng)景

在新安裝的 Arch 系統(tǒng)編譯安裝 PHP 失敗,提示錯(cuò)誤

configure: error: freetype-config not found.

編譯安裝的參數(shù)如下

sudo  ./configure --prefix=/usr/local/php 
--enable-fpm 
--with-fpm-user=php-fpm 
--with-fpm-group=php-fpm 
--with-config-file-path=/usr/local/php/etc 
--with-config-file-scan-dir=/usr/local/php/etc/conf.d 
--with-openssl 
--with-curl 
--with-gd 
--with-jpeg-dir 
--with-png-dir 
--with-zlib 
--with-freetype-dir=/usr 
--enable-mbstring 
--with-mysqli 
--enable-opcache 
--with-pdo-mysql 
--with-openssl 
--enable-mysqlnd  
--with-webp-dir 
--with-xpm-dir

原因

查找資料發(fā)現(xiàn)

They should really stop using this gross *-config script and start using pkg-config properly.

freetype-config 不再使用,而是使用 pkg-config
由于 php/ext/gd/config.m4 還是使用 freetype-config 而不是 pkg-config
導(dǎo)致報(bào) configure: error: freetype-config not found. 錯(cuò)誤.

詳細(xì)查看 php/ext/gd/config.m4 腳本

解決辦法

方法一

創(chuàng)建一個(gè)文件 /usr/sbin/freetype-config

#!/bin/sh

/usr/sbin/pkg-config freetype2 $@

重新編譯安裝,就可以了.

編譯出錯(cuò):/usr/local/src/php-7.2.9/ext/gd/gd.c:75:12: fatal error: ft2build.h: No such file or directory

方法二

編輯 php/ext/gd/config.m4 文件,把 freetype-config 替換為 pkg-config
FREETYPE2_CFLAGS, FREETYPE2_LIBS 增加參數(shù) freetype2

--- ext/gd/config.m4.orig
+++ ext/gd/config.m4
193c193
<       if test -f "$i/bin/freetype-config"; then
---
>       if test -f "$i/bin/pkg-config"; then
195c195
<         FREETYPE2_CONFIG="$i/bin/freetype-config"
---
>         FREETYPE2_CONFIG="$i/bin/pkg-config"
201c201
<       AC_MSG_ERROR([freetype-config not found.])
---
>       AC_MSG_ERROR([pkg-config not found.])
204,205c204,205
<     FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
<     FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
---
>     FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags freetype2`
>     FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs freetype2`

同理,configure 文件也做以上的修改,然后重新編譯即可.
最后采用 方法二 編譯安裝成功.

參考資料
things fail to build because freetype-config no longer exists
AUR(en)-php71

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容