php 裝配gd庫

來源:互聯網
上載者:User
php 安裝gd庫
php 安裝gd庫
1、查看php資訊
php -v

[[email protected] achievo]# php -v
PHP 5.3.6 (cli) (built: Aug 19 2011 19:35:20)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

2、
一、phpize是幹嘛的?

phpize是用來擴充php擴充模組的,通過phpize可以建立php的外掛模組



什麼時候我們要用phpize呢?

我們在安裝php時:

'./configure' '--prefix=/usr/local/php' '--with-mysql=/usr/local/mysql' '--with-zlib-dir' '--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-gd' '--enable-ftp' '--with-iconv' '--with-gettext' '--with-curl' '--enable-fastcgi' '--with-openssl'

後面根的參數是我們要的模組,但是隨著工作的需要,我們還要在加些模組,又不想重新編譯php,這些我們就可以用phpize了。



二、如何使用phpize?

當php編譯完成後,php的bin目錄下會有phpize這個指令檔 。在編譯你要添加的擴充模組之前,執行以下phpize就可以了;

------------------------------------
# 如果在編譯的時候忘記添加某些模組,可以使用這種辦法來重新編譯添加!
# 首先,進入PHP目錄(未編譯)的擴充目錄
cd /home/soft/php-5.2.14/ext/ftp/
# 調用phpize程式產生編譯設定檔
# find / -name phpize
/usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
# 編譯擴充庫
/configure –with-php-config=/usr/local/php/bin/php-config
make
# make成功執行後,產生的擴充庫檔案在目前的目錄的 modules 子目錄下
# 編輯php.ini文檔,找到extension_dir的目錄,將編譯好的擴充檔案複製到extension下面
vim /usr/local/php/etc/php.ini
# 第491行
# extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
cp ftp.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
# 在php.ini的添加擴充庫位置,設定要添加的擴充庫。
# 在612處添加 extension=ftp.so
# 重啟webservice
------------------------------------------------------
181的php源碼位置在
/root/software/php-5.3.6

----------------------------------------
這兩天嘗試在以上平台安裝個Xenforo論壇,安裝開始時提示以下資訊:

The following errors occurred while verifying that your server can run XenForo:

* The required PHP extension MySQLi could not be found. Please ask your host to install this extension.
* The required PHP extension GD could not be found. Please ask your host to install this extension.

由於PHP是源碼編譯安裝的,所以以上兩個擴充都沒安裝,下面是為PHP添加這兩個擴充的過程:


一、安裝GD擴充

1.下載安裝GD庫擴充所需源碼包(可點擊源碼包直接下載)

gd-2.0.35.tar.gz http://www.libgd.org/releases/

jpegsrc.v8b.tar.gz http://www.ijg.org/

libpng-1.5.0.tar.gz http://sourceforge.net/projects/libpng/

freetype-2.4.4.tar.gz http://sourceforge.net/projects/freetype/

zlib-1.2.3.tar.gz

2.分別編譯安裝各個源碼包

安裝zlib

tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install

安裝libpng

tar zxvf libpng-1.5.0.tar.tar
cd libpng-1.5.0
cd scripts
mv makefile.linux ../makefile
cd ..
make
make install

安裝freetype

tar zxvf freetype-2.4.4.tar.gz
cd freetype-2.4.4
./configure
make
make install

安裝Jpeg

tar zxvf jpegsrc.v8b.tar.gz
cd jpeg-8b
./configure –enable-shared
make
make test
make install
注意,這裡configure一定要帶–enable-shared參數,不然,不會產生共用庫

安裝GD庫
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure –with-png –with-freetype –with-jpeg
make install

3.重新編譯安裝PHP(即是在以前編譯PHP的參數後面再加上以上安裝的相關參數)

cd php-5.3.4 (進入以前的PHP源碼目錄)

./configure –prefix=/opt/php –with-mysql=/opt/mysql –with-apxs2=/opt/apache/bin/apxs –enable-track-vars –enable-force-cgi-redirect –with-config-file-path=/opt/php/etc –with-gd –enable-gd-native-ttf –with-zlib –with-png –with-jpeg –with-freetype –enable-sockets

綠色字型部份是以前安裝PHP時所加的參數

make

make install

這樣GD庫擴充便安裝完畢,重啟Apache,查看PHP資訊測試頁便可看到gd項;

二、安裝MySQLi擴充

在這裡要用到phpize,phpize 命令是用來準備 PHP 擴充庫編譯環境,一般在你安裝好PHP後,會在安裝PHP的bin目錄下找到這個命令。

如果在執行phpize命令後出現找不到autoconf之類的提示,請安裝好autoconf後再次執行。

以下指令的目錄路徑,請網友們根據自己系統的實際情況作相應修改。

PHP源碼包檔案夾下的EXT檔案夾就是放置著目前版本的可用擴充,CD進去看看都有哪些你需要的?應該看到mysqli檔案夾了吧~~~

cd /opt/software/php-5.3.4/ext/mysqli

在目前的目錄下執行phpize

[[email protected] mysqli]#/opt/php/bin/phpize

Configuring for:

PHP Api Version: 20090626

Zend Modeule Api No: 20090626

Zend Extension Api No: 220090626

[[email protected] mysqli]#./configure –prefix=/opt/mysqli –with-php-config=/opt/php/bin/php-config –with-mysqli=/opt/mysql/bin/mysql_config

[[email protected] mysqli]#make

[[email protected] mysqli]#make install

安裝完成後會有提示擴充所在目錄路徑,如:

/opt/php/lib/php/extensions/no-debug-zts-20090626

所需的mysqli.so便會在此目錄下,接下來修改/opt/php/etc/下的php.ini檔案,加入mysqli擴充,即加入如下一行:

extension=/opt/php/lib/php/extensions/no-debug-zts-20090626/mysqli.so

之後重新啟動Apache服務,再次開啟PHP資訊頁便可看到MySQLi項。

PHP其他擴充亦類似安裝。。。。


http://www.heiok.com/?p=517






  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.