In Ubuntu PHP does not support the FreeType of the GD library, resulting in the page verification code cannot be loaded

Source: Internet
Author: User
Tags phpinfo

1. Modify the source

Cp/etc/apt/sources.list/etc/apt/sources.list.bak

Vim/etc/apt/sources.list

First delete the contents, then write the following:

Deb Http://mirrors.163.com/ubuntu/precise main restricted universe multiverse

Deb Http://mirrors.163.com/ubuntu/precise-security main restricted universe multiverse

Deb Http://mirrors.163.com/ubuntu/precise-updates main restricted universe multiverse

Deb http://mirrors.163.com/ubuntu/precise-proposed main restricted universe multiverse

Deb Http://mirrors.163.com/ubuntu/precise-backports main restricted universe multiverse

DEB-SRC http://mirrors.163.com/ubuntu/precise main restricted universe multiverse

DEB-SRC http://mirrors.163.com/ubuntu/precise-security main restricted universe multiverse

DEB-SRC http://mirrors.163.com/ubuntu/precise-updates main restricted universe multiverse

DEB-SRC http://mirrors.163.com/ubuntu/precise-proposed main restricted universe multiverse

DEB-SRC http://mirrors.163.com/ubuntu/precise-backports main restricted universe multiverse

After saving, execute:

Apt-get Update

2. Installation Tools

Apt-get Install wget

Apt-get Install Vim

3, the establishment of test documents:

Under Apache Access directory, create a file phpinfo.php, write the following:

<?php

if (extension_loaded (' GD ')) {

Echo ' can use gd<br> ';

foreach (Gd_info () as $cate = = $value)

echo "$cate: $value <br>";

}else

Echo ' Can not use GD '

?>

Petitioning in the browser Q: http://test.com/phpinfo.php

can use GD

GD version:bundled (2.0.34 compatible)

FreeType support: #这里冒号后面没有值, stating that GD is not supported FreeType

T1lib Support:

GIF Read support:1

GIF Create support:1

JPEG support:1

PNG support:1

WBMP support:1

XPM Support:

XBM support:1

jis-mapped Japanese Font Support:

4. Download the relevant package

wget http://zlib.net/zlib-1.2.8.tar.gz

wget http://ftp.yzu.edu.tw/nongnu//freetype/freetype-2.6.tar.gz

wget https://github.com/libgd/libgd/releases/download/gd-2.1.1/libgd-2.1.1.tar.gz

wget http://cn2.php.net/distributions/php-5.4.30.tar.gz

wget http://www.ijg.org/files/jpegsrc.v9.tar.gz

wget http://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.21/libpng-1.6.21.tar.gz

5, apt-get-y install autoconf Libxml2-dev bzip2 OpenSSL

6. Unzip and install

TAR-XZVF freetype-2.6.tar.gz

TAR-XZVF php-5.4.30.tar.gz

TAR-XZVF zlib-1.2.8.tar.gz

TAR-XZVF libpng-1.6.21.tar.gz

TAR-XZVF jpegsrc.v9.tar.gz

TAR-XZVF libgd-2.1.1.tar.gz

CD libpng-1.6.21

./configure--prefix=/usr/local/libpng

Make && make install

CD zlib-1.2.8

./configure--prefix=/usr/local/zlib

Make && make install

CD freetype-2.6

CD builds/unix/

./configure--prefix=/usr/local/freetype--enable-shared

Cd.. /..

./configure--prefix=/usr/local/freetype--enable-shared

Make && make install

CD jpeg-9

./configure--prefix=/usr/local/jpeg

Make && make install

CD libgd-2.1.1

./configure--with-zlib=/usr/local/zlib/--with-png=/usr/local/libpng/--with-jpeg=/usr/local/jpeg/-- with-freetype=/usr/local/freetype/

Make && make install

7. Backup

Cp-r Php5_4_3 Php5_4_3bak

8. Building Module Link

cd/usr/lib/

Ln-s/usr/lib/x86_64-linux-gnu/libxpm.so.

Ln-s/USR/LIB/X86_64-LINUX-GNU/LIBXPM.A.

Ln-s/usr/lib/x86_64-linux-gnu/libxpm.so.4.

Ln-s/usr/lib/x86_64-linux-gnu/libxpm.so.4.11.0.

Ln-s/usr/lib/x86_64-linux-gnu/libssl.so.

Ln-s/bin/sed/usr/bin/sed

9. Compiling PHP

CD php-5.4.30

./configure--prefix=/home/clouder/vs/program/language/php/php5_4_3/--with-config-file-path=/home/clouder/vs/ program/language/php/php5_4_3/etc/--with-apxs2=/home/clouder/vs/program/webserver/apache/2_2_22/apache/bin/ Apxs--with-gd--with-iconv--with-jpeg-dir=/usr/local/jpeg/--with-zlib=/usr/local/zlib/--enable-xml-- Enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curlwrappers-- Enable-mbstring=all--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc --enable-zip--enable-soap--with-gettext--enable-session--enable-imap--enable-calendar--enable-eaccelerator= Shared--enable-wddx--with-freetype-dir=/usr/local/freetype/--without-pear

Make

Make install

10. Restart Apache

Can be restarted on the page, but after restarting confirm that the restart is successful: Available Ps-ef | grep HTTP Results View process time to determine

If the page restart is unsuccessful, try:

cd/home/clouder/vs/program/webserver/apache/2_2_22/apache/bin/

Apachectl restart

If there is an error, deal with it exactly.

11. Testing

Browser access: http://test.com/phpinfo.php

The result is:

can use GD

GD version:bundled (2.1.0 compatible)

FreeType support:1 #这里有值

FreeType Linkage:with FreeType #这里有值

T1lib Support:

GIF Read support:1

GIF Create support:1

JPEG support:1

PNG support:1

WBMP support:1

XPM Support:

XBM support:1

jis-mapped Japanese Font Support:

12, after the success will phpinfo.php this file delete


In Ubuntu PHP does not support the FreeType of the GD library, resulting in the page verification code cannot be loaded

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.