How to make PHP support GIF, png, JPEG at the same time
In RedHat6.2 by php's manual compile and install, found that only deal with GIF images, can not handle JPEG images. Later, I know that PHP handles images using the GD library, which initially supported the GIF. However, since the GIF uses a copyright controversial LZW algorithm that causes legal problems, GD libraries no longer support GD-1.6 GIF instead to support better, non-copyright-controversial PNGs. And I now want to support both GIF, PNG and JPEG.
1, Jpeg6b installation
There is already an RPM package in RedHat 6.2, and we do not need to go through the hard work of compiling it.
Into the installation disk
mount / mnt / cdrom
cd / mnt / cdrom / RedHat / RPMS
rpm -ivh libjpeg *
Installation is successful, with rpm -ql libjpeg-6b-10 view and found libjpeg.so.62.0.0 was copied to / usr / lib directory. Remember this directory, wait for a while with php to use.
2, GD-1.8.3 installation Get GD source address:
http://www.boutell.com/gd/
Of course you can compile your own, but it does not support jpeg, to patch.
Obtain patch source address is:
http://www.webofsin.com/gd-1.8.3-gif.patch
Next ... ............... trouble dead ... ... advise you still do not compile yourself! !
There are ready-made why not use it? Someone has patched the patch compiled, made RPM.
allowable:
http://rpmt.arvin.dk/rh7-backports/gd/
http://rpmt.arvin.dk/gd-with_gif/
get. There is such a good person in the world ; - <
Really touching! ! !
Download a few gd-with_gif * .rpm rpm-ivh gd-with_gif * installation.
Use rpm -ql gd-with_gif-1.8.3-7 View libgd.so.1.8.3 found under this directory / usr / gd-with_gif / lib, also need to use php.
3, PHP installation and configuration Given that I have heard that php4.0 does not support jpeg (not remember correctly), I suggest or use the latest version of php.
Below, we should be familiar with can not be familiar, right?
So I copied the manual PHP down:
---------------------------------
1. gunzip apache_1.3.x.tar.gz
2. tar xvf apache_1.3.x.tar
Gunzip php-xxxtar.gz
Tar xvf php-xxxtar
Cd apache_1.3.x
6. ./configure --PRefix = / www
7. cd ../php-xxx
Here is the key! ! !
./configure --with-MySQL --with-apache = .. / apache_1.3.x --enable-track-vars --with-jpeg-dir = / usr / lib --with-gd = / usr / gd-with_gif / lib
Of course, you can also add your own options, this does not go into details.
Make
10. make install
11. cd ../apache_1.3.x
12. for PHP 4: ./configure --activate-module = src / modules / php4 / libphp4.a
Make
14. make install
Instead of this step you may prefer to simply copy the httpd binary
overtop of your existing binary. Make sure you shut down your
server first though.
15. cd ../php-xxx
16. for PHP 4: cp php.ini-dist /usr/local/lib/php.ini
You can edit your .ini file to set PHP options
you prefer this file in another location, use
--with-config-file-path = / path in step 8.
17. Edit your httpd.conf or srm.conf file and add:
For PHP 4: AddType application / x-httpd-php .php
You can choose any extension you wish here. .php is simply the one
we suggest. You can even include .html.
18. Use your normal procedure for starting the Apache server. (You must
stop and restart the server, not just cause the server to reload by
use a HUP or USR1 signal.)
---------------------------------------
Finally succeeded, you can start apache phpinfo () Try and found gd there:
----------------------
gd
GD Support enabled
GD Version 1.6.2 or higher
GIF Support enabled
PNG Support enabled
JPG Support enabled
WBMP Support enabled
----------------------
^ _ ^ Ha ha ha ha ha ha ha ha ha ^ _ ^
You can now use all the php graphics functions:
ImageCreateFromGIF () & mdash; Create a new image from file or URL
ImageCreateFromJPEG () - Create a new image from file or URL
ImageCreateFromPNG () - Create a new image from file or URL
...
Absolutely no problem! ! ! !