Home  >  Article  >  Backend Development  >  How to install gd extension in php

How to install gd extension in php

藏色散人
藏色散人Original
2020-11-02 09:28:066425browse

How to install gd extension in php: First open the PHP configuration file "php.ini"; then remove the semicolon in front of "extension=php_gd2.dll" in "php.ini".

How to install gd extension in php

Recommended: "PHP Video Tutorial"

Linux/windows system installation php-gd extension library

Yesterday, a customer asked me a question. When he used the Ranzhi OA system, he was prompted with the following error window when displaying pictures. Seeing this error message, we will definitely think that PHP's gd library is not installed, but this friend said that he used phpinfo to check the PHP environment and found that the gd extension already exists, and the problem still exists, so the headache is caused by the problem. where. The following is the screenshot this friend gave me:

Seeing this, some attentive friends may have discovered the problem. It is obvious that this user's gd extension is not completely installed. Here I will directly show you the screenshot after the complete installation of the gd library:

So we are checking the PHP environment to see if the extension is fully installed and complete. In response to the above problems, we will share this article with you. How to completely install the php-gd extension in linux/windows systems.

linux system article

1.CentOS system

About GD extension

gd extension is an open source image processing library. It provides a series of APIs for processing images, so that it can be used to create charts, graphics, thumbnails and other image processing operations. The gd extension supports common image formats such as JPG, PNG, and GIF, so before installing the php-gd extension, we need to install libpng, jpegsrc, and freetype. In the following installation steps, you can adjust the specific path settings according to your actual situation.

Install freetype

wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.5.5.tar.gz
tar -xf freetype-2.5.5.tar.gz
cd freetype-2.5.5
./configure --prefix=/usr/local/freetype
make && make install

Install jpegsrc

wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9
./configure --prefix=/usr/local/jpeg
make && make install

Install libpng

wget http://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.31/libpng-1.6.31.tar.gz
tar zxvf libpng-1.6.31.tar.gz 
cd libpng-1.6.31
./configure --prefix=/usr/local/libpng
make && make install

Install GD extension

No longer recompile php, still use Add new extensions to phpize, be careful not to miss the make clean step.

cd /data/php-5.6.14/ext/gd/
 make clean
 /usr/local/php/bin/phpize
 ./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype
 make && make install

At this time, the gd.so file appears in the /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ directory.

Then modify the php.ini file and add a line

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/gd.so

Finally restart the service and check the php-gd extension information.

2.ubuntu system

sudo apt-get install php5-gd

Note that it is not php-gd but php5-gd.

Finally restart the service

windows article

Modify the PHP configuration file php.ini:

Place the php.ini collection extension=php_gd2.dll in front; just remove it.

Finally restart the service.

The above is the detailed content of How to install gd extension in php. 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