天天看點

php擴充子產品安裝 快速自動安裝

php開發簡單,速度快,以及擴充靈活,在最近一些年,越來越得到廣泛應用。 以前說到安裝php子產品,走過很多彎路。聽人說可以用:rpm包,也可以用源碼安裝。       
這些對于linux 初學者有時候真是一頭霧水。 其實,安裝擴充子產品并沒有想象那麼複雜,而且隻要我們用php 自帶的子產品安裝指令就可以很好的完成。 下面我說說,      
下載下傳,編譯,安裝一步到位的方法。       
1。安裝php 子產品安裝指令。      
wget http://pear.php.net/go-pear       
php go_pear      
php擴充子產品安裝 快速自動安裝
php擴充子產品安裝 快速自動安裝
代碼
[root@localhost ~]# php go-pear 
Welcome to go-pear!

Go-pear will install the \'pear\' command and all the files needed by
it.  This command is your tool for PEAR installation and maintenance.

Go-pear also lets you download and install the following optional PEAR
packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.


If you wish to abort, press Control-C now, or press Enter to continue: 

HTTP proxy (http://user:[email protected]:port), or Enter for none:: 

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type \'all\' to change all of them or simply press Enter to
accept these locations.

1. Installation prefix ($prefix) : /root
2. Temporary files directory     : $prefix/temp
3. Binaries directory            : $prefix/bin
4. PHP code directory ($php_dir) : $prefix/PEAR
5. Documentation base directory  : $php_dir/docs
6. Data base directory           : $php_dir/data
7. Tests base directory          : $php_dir/tests
      
1-7, \'all\' or Enter to continue:  
可以選擇:1 設定你安裝路徑。      
接下來,一路回車就可以完成安裝了。      
現在,你可以直接運作:pecl  pear 2個指令進行安裝。      
什麼是:pear  pecl 呢?      
php擴充子產品安裝 快速自動安裝
php擴充子產品安裝 快速自動安裝
代碼
Pear、Pecl都是PHP擴充子產品的集合。擴充PHP有兩種方法:   一種是用純粹的PHP代碼寫函數和類。  
Pear就是這樣一個項目。PEAR是PHP的官方開源類庫(PHP Extension and Application Repository的縮寫)。
Pear在英文中是梨子的意思。PEAR将PHP程式開發過程中常用的功能編寫成類庫,涵蓋了頁面呈面、資料庫通路、檔案操作、
資料結構、緩存操作、網絡協定等許多方面,使用者可以很友善地使用。它是一個PHP擴充及應用的一個代碼倉庫,
簡單地說,PEAR就是PHP的 cpan。其首頁是pear.php.net。  
更詳細的介紹可參考:http://www.shenmeshi.com/Computer/Computer_20071116151514.html  

另外一種是用c或者c++編寫外部子產品加載至php中。  
Pecl(The PHP Extension Community Library)就是幹這個事的,PHP的标準擴充,可以補充實際開發中所需的功能。
所有的擴充都需要安裝,在Windows下面以DLL的形式出現;在 linux下面需要單獨進行編譯,
它的表現形式為根據PHP官方的标準用C語言寫成,盡管源碼開放但是一般人無法随意更改源碼。
其首頁是 pecl.php.net。  最直接的表述:Pear是PHP的上層擴充,Pecl是PHP的底層擴充。  
這兩種方法其實都是為特定的應用提供現成的函數或者類,本質上來說都是一樣的。      
  知道上面 2個差別,對于我們安裝很友善了解了。我們一般so檔案擴充,需要運作:pecl
2.下面,我們安裝個:pecl_http擴充試下      
php擴充子產品安裝 快速自動安裝
php擴充子產品安裝 快速自動安裝
代碼
[root@localhost ~]# pecl search http
Retrieving data...0%
Matched packages, channel pecl.php.net:
=======================================
Package   Stable/(Latest) Local
pecl_http 1.7.0 (stable)        Extended HTTP Support
You have new mail in /var/spool/mail/root
[root@localhost ~]# pecl install pecl_http
downloading pecl_http-1.7.0.tgz ...
Starting to download pecl_http-1.7.0.tgz (173,979 bytes)
.....................................done: 173,979 bytes
71 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
whether to enable cURL HTTP requests; specify libcurl directory [yes] :       
先運作:search 指令模糊搜尋,然後可以用,pecl install pecl_http .      
 一路回車,一會兒 在:      
[root@localhost ~]# ll /usr/lib/php/modules/http.so 
-rw-r--r-- 1 root root 1274476 06-26 08:56 /usr/lib/php/modules/http.so      
存在自己的子產品了。(不同系統,位置可能不同),上一步安裝完後,會告訴子產品所在位址。      
3.配制php.ini       
加入:      
extension=http.so      
就ok了。       
然後,可以通過php -m  檢視下。      
[root@localhost ~]# php -m
[PHP Modules]
bz2
calendar
ctype
curl
date
dbase
dom
eAccelerator
exif
filter
ftp
gd
gettext
gmp
hash
http
。。。。。。。。。。。。。      
  已經安裝成功。
後記:其它也有源碼安裝,上pecl.php.net 找到對應源碼包解壓。可以通過:pecl install  源碼檔案。  一樣ok.       
php擴充子產品安裝 快速自動安裝