Method of adding freetype extension to PHP GD library

  • 2021-09-16 06:32:30
  • OfStack

Background: The imagefttext function was used for business requirements, and it was found that FreeType was not added when GD Library 1 was installed

linux Version centos 6.6

Installation process (since the server is a distributed intranet server, it cannot be installed using yum, and the following are compiled and installed after downloading the resource package):

Installing freetype

Extract freetype-2. 3.9. tar. gz

Compile and install

./configure--enable-static--enable-shared (prefix is not specified, the. h file is installed by default to/usr/local/include, and the. a. so file is installed by default to/usr/local/lib. If no directory is specified, it is also a sample to this location)

make & & make install

After confirming the successful installation of freetype, recompile and install the GD library and add freetype support

Install the gd library, version 2.0. 35

We recommend make clean first because there is a previous installation record, otherwise the installation may fail

./configure--enable-shared--with-jpeg=/usr/local/include/-with-freetype=/usr/usr/local/include/(Note here that path 1 of--

Confirm Support for Freetype 2. x library: yes

make & & make install

Recompile and install gd extension of PHP after confirming successful installation

php version 5.5. 38

Separate installation of the gd extension module requires cd to php-5. 5.38/ext/gd

Execute phpize to generate a compile file. If phpize is not introduced into the system, this file is in bin under the PHP installation directory

Here 1 must first execute make clean, this time installed 8 servers, did not first execute make clean 100% did not install successfully, did not add to freetype support

./configure --with-php-config=/opt/php5.5.38/bin/php-config --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir --with-gd

Verify that freetype 2 has been added in compilation

make & & make install

Confirm whether the newly generated. so file is the same as the path originally introduced in php. ini, and modify extension in php. ini if different

Restart php-fpm after successful installation

ps axu |grep php |grep -v 'grep'|awk '{print $2}'|xargs kill -9

/php5.5.38/sbin/php-fpm

After successful restart, check whether gd in phpinfo contains

FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.9

finished


Related articles: