您好,登錄后才能下訂單哦!
1、修改源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
先刪除里面的東西,再將下列寫入:
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
保存后,執行:
apt-get update
2、安裝工具
apt-get install wget
apt-get install vim
3、建立測試文件:
在apache訪問目錄下,建立文件phpinfo.php,寫入以下內容:
<?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'
?>
在瀏覽器上訪問:http://test.com/phpinfo.php
can use gd
GD Version: bundled (2.0.34 compatible)
FreeType Support: #這里冒號后面沒有值,說明gd不支持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、下載相關包
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、解壓并安裝
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、備份
cp -r php5_4_3 php5_4_3bak
8、建模塊鏈接
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、編譯php
cd php-5.4.30
./configure --prefix=/home/php/php5_4_3/ --with-config-file-path=/home/php/php5_4_3/etc/ --with-apxs2=/home/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、重啟apache
可以在頁面上重啟,但是重啟后請確認是否重啟成功:可用ps -ef | grep http 結果查看進程時間來確定
如果頁面重啟不成功,嘗試:
cd /home/apache/2_2_22/apache/bin/
apachectl restart
如果有錯誤,具體處理就行
11、測試
瀏覽器訪問:http://test.com/phpinfo.php
結果為:
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、成功后將phpinfo.php這個文件刪除
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。