php5 gd 庫文件安裝顯示驗證碼

LAMP攻略: 從新編譯PHP安裝擴展,GD庫安裝與配置

  LAMP攻略: LAMP環境搭建,Linux下Apache,MySQL,PHP安裝與配置中你們是否是總以爲漏了點什麼東西呢?對,那就是GD庫。這是咱們最經常使用的模塊之一。Linux下得GD庫安裝要比windows麻煩不少。本配置是在
CentOS-5.3
php-5.2.9
的擴展GD庫安裝。安裝用到的源碼:
gd-2.0.35
freetype-2.2.1
libpng-1.2.12
jpegsrc.v6b
能夠直接點擊到下載頁面下載。
若是你安裝linux系統時選擇了安裝 X 軟件開發。那麼極可能這些庫已經在你係統安裝上。至於怎麼查詢是否已經安裝和卸載,參考上一篇 LAMP攻略: LAMP環境搭建,Linux下Apache,MySQL,PHP安裝與配置
這個配置也基本適用於相應的red hat as 5或fedora版本中的配置

/*********************************************
*
* 做 者: 我不是魚
* LAMP中文網: http://www.lampchina.net
* PHP愛好者站: http://www.phpfans.net
* Email: deng5765@163.com
* 博 客:   http://www.lampchina.net/blog
*
*********************************************/

我已經把須要的源碼包下載到了 /usr/local/src 下了。
cd /usr/local/src
進入源碼包目錄,而後用ls列出用到的源碼包,
ls | grep -E 'jpeg|png|gd|free'
如圖


先安裝 freetype。
解壓
tar -zxvf freetype-2.2.1.tar.gz


進入解壓的目錄
cd freetype-2.2.1


安裝到/usr/local/freetype
./configure --prefix=/usr/local/freetype


編譯並安裝
make && make install


安裝完後再安裝png
執行
cd ../
回到源碼包目錄
解壓
tar -zxvf libpng-1.2.12.tar.gz


執行
cd libpng-1.2.12
進入解壓目錄
配置,編譯並安裝
./configure && make && make install


安裝完畢再安裝jpeg
執行
cd ../
回到源碼包目錄
解壓
tar -zxvf jpegsrc.v6b.tar.gz


進入解壓目錄
cd jpeg-6b
由於jpeg安裝不能自動建立文件夾,因此要先建立文件夾,不然會找不到文件夾而編譯失敗。
分別建立,如圖
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1


執行
./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static


編譯並安裝
make && make install


安裝完畢最後安裝gd
執行
cd ../
回到源碼包目錄
解壓
tar -zxvf gd-2.0.35.tar.gz


執行
cd gd-2.0.35
進入解壓包
執行
./configure --prefix=/usr/local/gb --with-jpeg --with-png --with-freetype


執行
make


執行
make install


好了,GD安裝完畢,如今用從新編譯php的方法安裝gd庫擴展。
上一章說到的lamp環境配置,個人php是解壓在 /usr/local/src/php-5.2.9
能夠直接進入這個目錄
cd /usr/local/src/php-5.2.9
而後從新配置php,配置是想保留原有配置的基礎上新增gd庫,
原有的配置可能不少人安裝就忘了,不要緊,這個能夠在phpinfo()的Configure Command 中看到
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/lib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql --with-zlib --enable-mbstring --enable-xml --with-gd --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir --with-freetype-dir=/usr/local/freetype


configure成功的話會看到 Thank you for using PHP 的字樣
執行
make


執行
make install


安裝完成後重啓apache
/usr/local/httpd/bin/apachectl -k restart


打開phpinfo頁面應該就能夠在Configure Command 及下面看到gd的信息

至此,PHP擴展GD庫安裝完成。下一篇咱們談談如何用phpize來安裝php擴展。
相關文章
相關標籤/搜索