Let your PHP support GIF, png, and JPEG at the same time
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

To delete an extra ServerName directive from Apache, you can take the following steps: Identify and delete the extra ServerName directive. Restart Apache to make the changes take effect. Check the configuration file to verify changes. Test the server to make sure the problem is resolved.
