Install PHP in Linux, and Gd supports JPEG

Source: Internet
Author: User

Brief Introduction: This is a detailed page for installing PHP in Linux and supporting JPEG in GD. It introduces PHP, PHP, Gd, libjpeg, Linux, imagecreatefromjpeg and installing PHP in Linux, GD supports JPEG-related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 348690 'rolling = 'no'>
A colleague suddenly told me that an error was reported when I got a project server over the past few days.

 
: Fatal error: Call to undefined function imagecreatefromjpeg ()

Solution:

[Size = large]

1. reinstall PHP. Do not install GD.

[Size]

#. /Configure -- prefix =/usr/local/PHP -- With-config-file-Path =/etc \ -- With-mysql =/usr/local/MySQL -- With-iconv-Dir \ -- With-zlib -- With-libxml-dir -- enable-XML -- disable-Debug -- disable-rpath \ -- enable-discard-path -- enable-safe-mode -- enable-bcmath -- enable-shmop \ -- enable-sysvsem -- enable-inline-optimization -- With-curl \ -- With-curlwrappers -- enable-mbregex -- enable-FastCGI -- enable-FPM \ --- iconv =/usr/local -- enable-force-CGI-redirect -- enable-mbstring -- With-OpenSSL \ # Make & make install

2. Add the libjpeg. So Library Under/lib,/usr/lib,/usr/local/lib (soft connection is required)

 
Ln-SV/usr/lib/libjpeg. so.62.0.0/lib/libjpeg. So

3. Go to the EXT/GD directory under the PHP source code and compile and install GD.

 
#. /Configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config -- With-JPEG-Dir \ -- With-FreeType-Dir # Make & make install

4. Configure PHP. ini to add

Extension = Gd. So

Restart nginx and PHP-FPM

Solution Process:

The previous query showed that GD does not support JPEG. Open phpinfo and check it.

1. Re-compile and install PHP

 
. /Configure -- prefix =/usr/local/PHP -- With-config-file-Path =/etc \ -- With-mysql =/usr/local/MySQL -- With-iconv-Dir \ -- With-Gd -- enable-Gd-native-TTF -- With-FreeType-dir -- With-PNG-dir -- With-JPEG-Dir \ -- With-zlib -- With-libxml -dir -- enable-XML -- disable-Debug -- disable-rpath \ -- enable-discard-path -- enable-safe-mode -- enable-bcmath -- enable-shmop \ -- enable-sysvsem -- enable-inline-optimization -- With-curl \ -- With-curlwrappers -- enable-mbregex -- enable-FastCGI -- enable-FPM \ -- With-iconv =/usr/local -- enable- force-CGI-redirect -- enable-mbstring -- With-OpenSSL \ Make & make install

Check phpinfo again. The result is not found yet.

2. The online search "GD supports jpeg" result is that many people have encountered the same problem.

1. Some people say that the built-in GD of PHP does not support

2. Some people say they need to install JPEG on their own.

3. reinstall the SDK.

Therefore, check whether your JPEG has been installed.

# Rpm-QL libjpeg

I found that I have installed libjpeg, and i386 and x86_64 have been installed (in fact, one is enough ).

This is why I have installed it. Think about the self-installed GD that comes with PHP. So it will be installed under the php-5.2.17/EXT/GD, run the following:

 
# Phpize #. /configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config -- With-JPEG-Dir \ -- With-FreeType-Dir # Make & make install

Add "extention = Gd. So" to PhP. ini and restart nginx and PHP-FPM. (If you install Apache, restart Apache)

Tip: GD already Load

Oh... PHP has been installed just now. You have to reinstall PHP and remove the GD-related parameters (the third line above)

#. /Configure -- prefix =/usr/local/PHP -- With-config-file-Path =/etc \ -- With-mysql =/usr/local/MySQL -- With-iconv-Dir \ -- With-zlib -- With-libxml-dir -- enable-XML -- disable-Debug -- disable-rpath \ -- enable-discard-path -- enable-safe-mode -- enable-bcmath -- enable-shmop \ -- enable-sysvsem -- enable-inline-optimization -- With-curl \ -- With-curlwrappers -- enable-mbregex -- enable-FastCGI -- enable-FPM \ --- iconv =/usr/local -- enable-force-CGI-redirect -- enable-mbstring -- With-OpenSSL \ # Make & make install

Restart nginx and PHP-FPM

GD has been loaded, but its uncle does not have JPG ....

It must be a problem when GD is installed. So run under the php-5.2.17:

 
# Make clean # cd EXT/GD # phpize

Generate the configure file, debug the configure file, and find libjpeg. so is under/usr/local/lib by default (it seems that different computer situations ). so I made a soft connection under/usr/local/lib, re-compiled and installed GD, and finally succeeded. I finally figured it out. It took me a whole day.

Love J2EE follow Java Michael Jackson video station JSON online tools

http://biancheng.dnbcw.info/php/348690.html pageno: 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.