Home  >  Article  >  Backend Development  >  How to add freetype extension to PHP GD library

How to add freetype extension to PHP GD library

不言
不言Original
2018-03-29 17:13:342739browse

This article is mainly to share with you the method of adding freetype expansion to the PHP GD library. Friends in need can refer to it

Background: The imagefttext function is required for business needs. I found that the GD library was installed at the beginning. FreeType

linux version centos 6.6

Installation process (because 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 (If prefix is ​​not specified, .h files will be installed to /usr/local/include by default, and .a|.so files will be installed to /usr/local/lib by default. If no directory is specified, the installation of other resource packages will also go to this location)

make && make install

Confirm that freetype is installed successfully and recompile and install the GD library, add freetype support

Install the gd library, version 2.0.35

Because 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 of --with-freetype=/usr/local/ is initially written as /usr/local/lib, and the result is always imported. freetype failed, probably because the header file is not in this directory, and was successfully introduced after changing to the upper-level directory)

Confirm Support for Freetype 2.x library: yes

make && make install

After confirming that the installation is successful, recompile and install the PHP gd extension

php version 5.5.38

Installing the gd extension module separately requires 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, 8 servers are installed. If you do not execute make clean first, the installation is 100% unsuccessful, and it is not 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 has been added in the compilation

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 the extension in php.ini

Restart after successful installation 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

FreeType Linkage with freetype

FreeType Version 2.3 .9

finished



The above is the detailed content of How to add freetype extension to PHP GD library. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn