解决编译PHP7时gd2不支持freetype

2023年02月03日 2087点热度 0人点赞 0条评论

今天下午在CentOS8上编译PHP7时发现一个怪问题,GD2不支持freetype!这个很重要,大多数自动生成验证码或是在图片上增加文字的程序都需要,找了半天原因,把编译参数记录如下:
php7.4

./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
--with-fpm-user=www --with-fpm-group=www \
--with-iconv --with-zlib --enable-xml --with-xsl \
--with-webp --with-curl --enable-bcmath \
--enable-shmop --enable-sysvsem --enable-sysvshm \
--enable-mbregex --enable-mbstring --with-openssl \
--with-bz2 --with-pdo-mysql --with-pdo-sqlite \
--enable-pcntl --enable-sockets --with-pear \
--with-mysqli --with-pdo-mysql --enable-ftp --enable-fpm \
--enable-opcache --enable-exif --enable-pcntl --enable-pdo \
--enable-bcmath --enable-mbregex --enable-shmop \
--enable-soap --enable-sysvsem --enable-cli \
--enable-intl --enable-calendar --enable-static \
--enable-ftp --with-gettext --with-gmp \
--enable-shmop --enable-ipv6 --with-system-ciphers \
--with-xpm --with-jpeg --with-webp --with-freetype --enable-gd

最重要就是最后一排:

--with-xpm --with-jpeg --with-webp --with-freetype --enable-gd

php7.3

./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
--with-fpm-user=www --with-fpm-group=www \
--with-iconv --with-zlib --enable-xml --with-xsl \
--with-webp --with-curl --enable-bcmath \
--enable-shmop --enable-sysvsem --enable-sysvshm \
--enable-mbregex --enable-mbstring --with-openssl \
--with-bz2 --with-pdo-mysql --with-pdo-sqlite \
--enable-pcntl --enable-sockets --with-pear \
--with-mysqli --with-pdo-mysql --enable-ftp --enable-fpm \
--enable-opcache --enable-exif --enable-pcntl --enable-pdo \
--enable-bcmath --enable-mbregex --enable-shmop \
--enable-soap --enable-sysvsem --enable-cli \
--enable-intl --enable-calendar --enable-static \
--enable-ftp --with-gettext --with-gmp \
--enable-shmop --enable-ipv6 --with-system-ciphers \
--with-freetype-dir --with-xpm-dir --with-jpeg-dir --with-webp-dir --with-gd

最重要就是最后一排,注意和7.4版本的区别:

--with-freetype-dir --with-xpm-dir --with-jpeg-dir --with-webp-dir --with-gd

路灯

这个人很懒,什么都没留下

文章评论