Let your PHP support GIF, png, and JPEG at the same time
Compile and install according to the manual of php on RedHat6.2, and found that it can only process GIF images, not JPEG images. Later I learned that PHP uses the GD library to process images, and 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 no longer supports it. GIF, instead support the better, copyright-free PNG. And now I want to support GIF, PNG and JPEG at the same time.
1. Jpeg6b installation
There is already an RPM package in RedHat6.2, so we don’t need to compile it hard.
Insert the installation disk
mount /mnt/cdrom
cd /mnt/cdrom/RedHat/RPMS
rpm -ivh libjpeg*
The installation is successful, use rpm -ql libjpeg-6b-10 to check and find libjpeg.so.62.0.0 It is copied to the /usr/lib directory. Remember this directory, you will need it later when configuring php.
2. Installation of GD-1.8.3
The address to obtain the GD source code is:
http://www.boutell.com/gd/
Of course you can compile it yourself, but it does not support jpeg and needs to be patched.
The address to obtain the source code of the patch is:
http://www.webofsin.com/gd-1.8.3-gif.patch
The next step.........it's very troublesome...I advise you not to compile it yourself! !
Why not use something already available? Someone has already patched it and compiled it into an RPM.
Available at:
http://rpms.arvin.dk/rh7-backports/gd/
http://rpms.arvin.dk/gd-with_gif/
Get it. There are such good people in the world? ;-<
How touching! ! !
After downloading several gd-with_gif*.rpm, directly install rpm -ivh gd-with_gif*.
Use rpm -ql gd-with_gif-1.8.3-7 to view
Found that libgd.so.1.8.3 is placed under /usr/gd-with_gif/lib
Remember this directory and use it when configuring PHP.
3. PHP installation and configuration
Since I heard that php4.0 does not support jpeg (I don’t know if I remember correctly), I recommend using the latest version of php.
Everyone should be familiar with the following, right?
So I copied the php manual:
---------------------------------
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
Of course you can also add your own options, so I won’t go into details here.
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 by
Use a HUP or USR1 signal.)
---------------------------------------
It finally succeeded. You can start apache and try phpinfo() and 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
----------------------
^_^ Hahahahahahahahahahaha ^_^
You can now use all php graphics 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! ! ! !
The above has introduced how to make your PHP support GIF, png, and JPEG at the same time, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.