Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install GD Library in PHP under Centos7

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to install gd library in PHP under Centos7. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

It is easy to install php under Centos7, or gd library support for php.

Everything is done through yum.

Yum install php-gd

The above command will take care of the support of php-gd. Let's see if phpinfo supports it.

However, if you need to use different versions of php, it is quite troublesome, after groping, the author found a relatively simple way.

Since multiple php versions need to coexist 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 and let me know)

So, the support of compiling php-gd is mostly through compiling freetype, libpng, libjpeg … Very complicated, the author through one by one to try, found that still not successful! Later, I found that the gd library I compiled did not include support for jpeg and libpng.

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

Note: if you successfully see gd support png in the source version of php by compiling the source code yourself, then congratulations, you are so lucky.

Let's talk about my method:

Use system libraries as much as possible, or libraries that can be installed from yum sources, such as gd, libpng, libjpeg, libfreetype... Everything, the source of centos is ready, we just want a different version of php. Since we need source code to compile php, we need to install the corresponding source code version, as well as the version with the devel logo.

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

Under the php source directory: if there is an error in the undefined gdXXX function, you need to clean the compiled result.

Make clean

Make 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: here we do not need to specify the location of the specific gd, jpeg, png, freetype directories, just use the version under the system directory (save time and effort).

After this installation, the gd library will follow ok, and the newly produced libphp5.so files have been installed in the specified apache's moduls directory.

GD Support enabledGD Version bundled (2.1.0 compatible) FreeType Support enabledFreeType Linkage with freetypeFreeType Version 2.4.11GIF Read Support enabledGIF Create Support enabledJPEG Support enabledlibJPEG Version 6bPNG Support enabledlibPNG Version 1.5.13WBMP Support enabledXBM Support enabled

Why can we save effort? The gd library that should be installed for centos has already connected jpeg, png and other libraries. It can be proved by ldd liggd.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) these are all the contents of the article "how to install the gd Library in PHP under Centos7" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report