Examples of PHP installation gd libraries under Centos7

  • 2020-11-03 22:39:45
  • OfStack

Installing php under Centos7, or php's gd library support, is straightforward.

1 cut through yum.


yum install php-gd 

The above command fixes php-ES12en support. Check to see if phpinfo supports it.

However, if different versions of php were needed, it would be quite troublesome. After exploration, the author found a relatively simple way.

Since you need to co-exist with multiple versions of php with the native version of the system, the version you require must be compiled with source code. (If there is any other way, please remember to reply to me.)

So, compile ES22en-ES23en support, most of the network is by compiling freetype, libpng, libjpeg... Very complex, the author through 11 try, find or not successful!! It turned out that the gd library I compiled did not include support for jpeg and libpng.

(ldd libgd. so. 2 by looking at the dependencies of your compiled dynamic library files)

Note: If you have managed to see gd support for png in the source version of php by compiling the source code yourself, you are lucky.

Here's my approach:

Use the system libraries where possible, or the yum source can be installed, such as gd, libpng, libjpeg, libfreetype... 1 cut, the source of centos is ready, we just want a different version of php. Since we need to compile THE source code for php, we need to install the corresponding source code version, along with the version identified by devel.


yum install libpng libpng-devel libjpeg-turbo libjpeg-turbo-devel freetype freetype-devel gd

In the php source directory: if an error occurs with the gdXXX function undefined, the result of the compilation under clean1 is required.


make clean 

Under make1 again:


 ' ./configure'  '� with-mysql'  '� with-apxs2=/usr/local/apache2/bin/apxs'  '� with-curl'  '� with-gd'  '� with-jpeg-dir'  '� with-png-dir'  '� with-freetype-dir' 

Note: We do not need to specify the specific location of gd, jpeg, png, freetype directory, directly using the system directory version (save time and effort oh).

After this installation, the gd library follows ok and the newly produced libphp5.so file has been installed in the moduls directory of the specified apache.


GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.4.11
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.5.13
WBMP Support enabled
XBM Support enabled

Why can we save effort? The gd library that should be installed for centos has connected jpeg, png, etc. It can be proved by ldd ES86en. so. 2:


[root@iZ25mdbcou0Z ~]# ldd /usr/lib64/libgd.so.2 
linux-vdso.so.1 => (0x00007fff591fe000) 
libXpm.so.4 => /lib64/libXpm.so.4 (0x00007f91ed0c8000) 
libX11.so.6 => /lib64/libX11.so.6 (0x00007f91ecd8a000) 
libjpeg.so.62 => /lib64/libjpeg.so.62 (0x00007f91ecb34000) 
libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f91ec8f8000) 
libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f91ec652000) 
libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f91ec426000) 
libz.so.1 => /lib64/libz.so.1 (0x00007f91ec210000) 
libm.so.6 => /lib64/libm.so.6 (0x00007f91ebf0e000) 
libc.so.6 => /lib64/libc.so.6 (0x00007f91ebb4c000) 
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f91eb92b000) 
libdl.so.2 => /lib64/libdl.so.2 (0x00007f91eb727000) 
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f91eb4fc000) 
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f91eb2e0000) 
/lib64/ld-linux-x86-64.so.2 (0x00007f91ed52b000) 
libXau.so.6 => /lib64/libXau.so.6 (0x00007f91eb0dc000)

Related articles: