Home  >  Article  >  Backend Development  >  Learning dynamic web technology PHP: Detailed explanation of GD library installation problems_PHP tutorial

Learning dynamic web technology PHP: Detailed explanation of GD library installation problems_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:30:10898browse

For the convenience of installation, I wrote a part of the GD installation process myself, and now publish it. I hope friends can give me more opinions, thank you! It turns out that GD does not support WBMP, but now GD has been expanded to support WBMP.

Question:

After installing RedHat 7.2, I started programming in PHP and found that I could only process GIF images, not JPEG images.

Later I learned that PHP uses the GD library to process images. The GD library initially supported GIF. However, because GIF used the copyright-controversial LZW algorithm, it would cause legal problems, so starting from GD-1.6, the GD library GIF is no longer supported in favor of the better, copyright-free PNG. And now I want to support GIF, PNG and JPEG at the same time. Introduced in order from bottom to top, that is, Jpeg->ttf->zlib->png->GD->PHP->Apache.

1.Jpeg6b installation and configuration

The main files of Jpeg include jpeglib.h, libjpeg.a, libjpeg.so, etc. First check whether it is installed in the system. Go to the /usr/include directory to see if there is jpeglib.h, and go to the /usr/lib directory to see if there are libjpeg.a and libjpeg.so. My system does not have it, so I need to install it.

The address to obtain the Jpeg source code is:


 ftp://ftp.uu.net/graphics/jpeg/

The obtained file is jpegsrc.v6b.tar.gz and is placed in the /usr/src directory.

Go to the /usr/src directory and start the installation process. Enter /usr/src:

cd /usr/src

Unzip the compressed file:

tar xzvf jpegsrc.v6b.tar.gz

After the command is completed, there is an additional subdirectory jpeg-6b, in which the Jpeg source code file is located. Enter this subdirectory:

 cd jpeg-6b

The install.doc file in this directory details how to install Jpeg, just follow the instructions. Configure the generated Makefile:

 ./configure

After the command is completed, there will be an additional Makefile file in the directory. Makefile is a configuration and process control file for compilation and installation of many software. It is very important and you should learn to understand its contents. Start compiling:

make

After the command is completed, there are many more files in the directory, the most important of which are libjpeg.a and libjpeg.so. Installation:

make install

After the command is completed, jpeglib.h is copied to the /usr/include directory, and libjpeg.a and libjpeg.so are copied to the /usr/local/lib directory

2. Installation and configuration of ttf

http://www.freetype.org
freetype-1.3.1.tar.gz
tar -xzvf freetype-1.3.1.tar.gz
./configure

After the command is completed, there will be an additional Makefile file in the directory. Makefile is a configuration and process control file for compilation and installation of many software. It is very important and you should learn to understand its contents. Start compiling:

make
make install

There was an error dont found the freetype.h when compiling gd, so

 cp /usr/local/include/freetype/* /usr/local/include/

3, zlib installation:

Becaust the note, you must install the zlib first!
Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be placed in another directory , at the same level as libpng.
Note that your system might already have a preinstalled
zlib, but you will still need to have access to the
zlib.h and zconf.h include files that correspond to the
 version of zlib thats installed.
 http://www.gzip.org/zlib/
 ftp://ftp.uu.net/graphics/png/src/zlib-1.1.3. tar.gz
./configure
make
make install

4. libpng installation:

Read INSTALL

http://www.libpng.org/pub/png/
libpng-1.2.0.tar.gz
UNIX example: cp scripts/makefile.std makefile
make
make install

5.GD-1.8.3 installation and configuration

The main files of GD include gd.h, libgd.a, etc. The address to obtain the GD source code is: http://www.boutell.com/gd/

The obtained file is gd-1.8.3.tar.gz, which is placed in the /usr/src directory. It is known that this version of GD does not support GIF, but thinking about it, there are many people like me who hope that GD supports both GIF and JPEG, so someone made a patch to add support for GIF. It looks like this is a British guy. His email address is adam@elysium.ltd.uk. The address to obtain the patch source code is: http://www.webofsin.com/gd-1.8.3-gif.patch. The obtained file is gd-1.8.3-gif.patch and is placed in the /usr/src directory. Enter /usr/src:

cd /usr/src

Unzip the compressed file:

tar xzvf gd-1.8.3.tar.gz

After the command is completed, there is an additional subdirectory gd-1.8.3, in which the source code files of GD are located. Patch the source code:

patch -p0

After the command is completed, there is an additional gd_gif.c file in the gd-1.8.3 subdirectory, and the files gd.h and Makefile have also been modified accordingly. Enter this subdirectory:

cd gd-1.8.3

By default, the GD library does not include JPEG support when compiling, so the Makefile must be modified. Modify the Makefile so that:

CFLAGS=-O -DHAVE_XPM -DHAVE_JPEG -DHAVE_LIBTTF
LIBS=-lm -lgd -lpng -lz -ljpeg -lttf -lXpm -lX11

After that, compile and install:

make
make install

After the command is completed, gd.h is copied to the /usr/local/include directory, and libgd.a is copied to the /usr/local/lib directory.

php apache installed in SO mode:

6. Installation and configuration of php-4.0.6

The main files of PHP include libphp4.a, libphp4.so, etc. The address to obtain PHP source code is: http://php.net

The obtained file is php-4.0.6.tar.gz, which is placed in the /usr/src directory.

Enter the /usr/src directory and extract the file:

cd /usr/src
tar xzvf php-4.0.6.tar.gz

After the command is completed, there is an additional subdirectory php-4.0.6, in which the PHP source code files are located. Enter this subdirectory:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509194.htmlTechArticleFor the convenience of installation, I wrote a GD installation process myself and now publish it. I hope friends will mention it more Thank you for your opinion! Originally GD did not support WBMP, but now GD has been expanded to support WBMP. Question: Install Red...
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