Home > Article > Backend Development > Add freetype extension to GD library in PHP
Business requirements require the use of the imagefttext function. It was found that FreeType was not added when the GD library was initially installed. This article mainly shares with you a method of adding freetype expansion to the PHP GD library. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.
linux version centos 6.6
Installation process (since the server is a distributed intranet server, it cannot be installed using yum. The following are compiled and installed after downloading the resource package) :
Install freetype
Unzip freetype-2.3.9.tar.gz
Compile and install
./configure --enable-static --enable-shared (without specifying prefix, .h files are installed to /usr/local/include by default, .a|.so files are installed to /usr/ by default The installation of other resource packages in local/lib is the same if no directory is specified. Go to this location)
make && make install
Confirm that the freetype installation is successful and then recompile and install the GD library and add freetype support
Install gd library, version 2.0.35
Since there are previous installation records, it is recommended to make clean first, otherwise the installation may fail
./configure --enable-shared --with-jpeg=/usr/local/include/ --with-freetype=/usr/local/ --with-png=/usr/local/include/ (It should be noted here that the path to --with-freetype=/usr/local/ was originally written as /usr/local/lib. As a result, freetype always failed to be introduced. It is probably because the header file is not in this directory. The introduction was successful after changing to the upper level directory)
Confirm Support for Freetype 2.x library: yes
make && make install
Confirm the installation After success, recompile and install PHP's gd extension
php version 5.5.38
To install the gd extension module separately, you need to cd to php-5.5. 38/ext/gd
Execute phpize to generate a compiled file. If phpize is not introduced into the system, this file will be in the bin in the PHP installation directory.
Be sure to execute make clean here first. This time Installed 8 servers, 100% of them were not installed successfully without executing make clean first, and none of them were added 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
Confirm that freetype 2 is compiling has been added
make && make install
Confirm whether the newly generated .so file is the same as the path originally introduced in php.ini. If it is different, you need to modify php.ini. extension
After successful installation, restart php-fpm
ps axu |grep php |grep -v 'grep'|awk '{print $2}'|xargs kill -9
/php5.5.38/sbin/php-fpm
After the restart is successful, check whether the gd in phpinfo contains
FreeType Support | enabled |
with freetype | |
2.3.9 |
The above is the detailed content of Add freetype extension to GD library in PHP. For more information, please follow other related articles on the PHP Chinese website!