Make your PHP support GIF, png, and JPEG at the same time
After RedHat6.2 is compiled and installed by php manual, it is found that only GIF images can be processed and JPEG images cannot be processed. Later, I learned that PHP used the GD library to process images, and the GD library started to support GIF. However, because GIF uses the copyrighted LZW algorithm, it may cause legal problems, so from the beginning of the GD-1.6, GD library no longer support GIF, changed to support better, no copyright dispute PNG. Now I want to support both GIF, PNG and JPEG.
1. Jpeg6b Installation
The RPM package already exists in RedHat6.2, so we don't need to compile it.
Mount the disk
Mount/mnt/cdrom
Cd/mnt/cdrom/RedHat/RPMS
Rpm-ivh libjpeg *
The installation was successful. Run the rpm-ql libjpeg-6b-10 to check and find that libjpeg. so.62.0.0 was copied to the/usr/lib directory. Remember this directory and use it later for php configuration.
2. GD-1.8.3 Installation
The address for getting GD source code is:
Http://www.boutell.com/gd/
Of course you can compile it by yourself, but it does not support jpeg and requires patching.
The address for obtaining the patch source code is:
Http://www.webofsin.com/gd-1.8.3-gif.patch
Next .................. So annoying ...... Advise you not to compile it yourself !!
Why don't we need something ready for use? Someone has already completed the patch compilation and made it an RPM.
You can:
Http://rpms.arvin.dk/rh7-backports/gd/
Http://rpms.arvin.dk/gd-with_gif/
. Is there such a good person in the world ?; -<
It's amazing !!!
Download several gd-with_gif *. rpm and install directly rpm-ivh gd-with_gif.
View with rpm-ql gd-with_gif-1.8.3-7
Found libgd. so.1.8.3 put under/usr/gd-with_gif/lib
Remember this directory and use it when configuring php.
3. install and configure PHP
I have heard that php4.0 does not support jpeg (I remember it wrong). I suggest using the latest php version.
Below, you should be familiar with it again?
So I copied the manual of php:
---------------------------------
1. gunzip apache_1.3.x.tar.gz
2. tar xvf apache_1.3.x.tar
3. gunzip php-x.x.x.tar.gz
4. tar xvf php-x.x.x.tar
5. cd apache_1.3.x
6../configure -- prefix =/www
7. cd./php-x.x.x
8. 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
You can also add your own options.
9. make
10. make install
11. cd ../apache_1.3.x
12. for PHP 4:./configure -- activate-module = src/modules/php4/libphp4.a
13. 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-x.x.x
16. for PHP 4: cp php. ini-dist/usr/local/lib/php. ini
You can edit your. ini file to set PHP options. If
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
Use a HUP or USR1 signal .)
---------------------------------------
Finally, you can start apache and try it with phpinfo () to find gd:
----------------------
Gd
GD Support enabled
GD Version 1.6.2 or higher
GIF Support enabled
PNG Support enabled
JPG Support enabled
WBMP Support enabled
----------------------
^_^ Haha ^_^
Now you can use all the php graphic functions:
ImageCreateFromGIF ()-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 !!!!