- [root@jbxue 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
複製代碼二,phpize1,什麼是phpizephpize用來擴充php擴充模組,通過phpize可以建立php的外掛模組。 在安裝php時,需要用到phpize:
- './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來協助外掛模組。 2,如何使用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.分別編譯安裝各個源碼包 1)、安裝zlib
- tar zxvf zlib-1.2.3.tar.gz
- cd zlib-1.2.3
- ./configure
- make
- make install
複製代碼2)、安裝libpng
- tar zxvf libpng-1.5.0.tar.tar
- cd libpng-1.5.0
- cd scripts
- mv makefile.linux ../makefile
- cd ..
- make
- make install
複製代碼3)、安裝freetype
- tar zxvf freetype-2.4.4.tar.gz
- cd freetype-2.4.4
- ./configure
- make
- make install
複製代碼4)、安裝Jpeg
- tar zxvf jpegsrc.v8b.tar.gz
- cd jpeg-8b
- ./configure –enable-shared
- make
- make test
- make install
-
複製代碼注意,這裡configure一定要帶–enable-shared參數,不然,不會產生共用庫。 5)、安裝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
- [root@jbxue mysqli]#/opt/php/bin/phpize
- Configuring for:
- PHP Api Version: 20090626
- Zend Modeule Api No: 20090626
- Zend Extension Api No: 220090626
- [root@jbxue mysqli]#./configure –prefix=/opt/mysqli –with-php-config=/opt/php/bin/php-config –with-mysqli=/opt/mysql/bin/mysql_config
- [root@jbxue mysqli]#make
- [root@jbxue 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項。 |