PHP pear安裝配置教程
什么是PEAR?
PEAR是PHP擴(kuò)展與應(yīng)用庫(the PHP Extension and Application Repository)的縮寫。它是一個(gè)PHP擴(kuò)展及應(yīng)用的一個(gè)代碼倉(cāng)庫,簡(jiǎn)單地說,PEAR之于PHP就像是CPAN(Comprehensive Perl Archive Network)之于Perl。
由此可見PEAR是PHP代碼的倉(cāng)庫,在這里可以找到很多有用的代碼,避免我們重復(fù)寫一些功能,但是PEAR代碼包并不是直接通過HTTP網(wǎng)站下載的,我們需要安裝PEAR。
如何獲取并安裝PEAR
建議:下面操作在Windows 7環(huán)境下完成,同樣適用于Windows XP/2003/Vista/2008系統(tǒng),部分操作帶有嘗試性,為了避免彎路,建議先看完本文,然后再進(jìn)行相關(guān)操作。
如果PHP目錄下沒有自帶PEAR,即找不到go-pear.php文件,那么就需要我們手動(dòng)下載go-pear.php文件,點(diǎn)擊這里下載并另存為go-pear.php,這個(gè)文件放到php.exe所在的PHP安裝目錄下,我這里安裝目錄是D:\php5(下文以此目錄為準(zhǔn)),那么go-pear.php的位置應(yīng)該是D:\php5\go-pear.php。
開始 – 運(yùn)行,輸入cmd,啟動(dòng)命令提示符,輸入以下命令,主要是切換到go-pear.php目錄下,然后執(zhí)行這個(gè)PHP腳本文件:
cd D:\php5
D:
php go-pear.php
遺憾的是可能由于我的PHP版本太新,上述操作提示失敗,具體的信息如下:
Deprecated: Assigning the return value of new by reference is deprecated in D:\php5\go-pear.php on line 733
Sorry! Your PHP version is too new (5.3.8) for this go-pear.
Instead use http://pear.php.net/go-pear.phar for a more stable and current version of go-pear, more suited to your PHP version.
Thank you for your coopertion and sorry for the inconvenience!
意思是要求我們到http://pear.php.net/go-pear.phar下載go-pear.phar文件,然后取代go-pear.php再試。下載好go-pear.phar文件并放到D:\php5文件夾中,執(zhí)行下面的命令:
cd D:\php5
D:
php go-pear.phar
這時(shí)出現(xiàn):
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :
按回車默認(rèn)system然后繼續(xù)。以下是默認(rèn)的pear的臨時(shí)、數(shù)據(jù)、配置、測(cè)試、執(zhí)行目錄的設(shè)置:
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 base ($prefix) : D:\php5 2. Temporary directory for processing : D:\php5\tmp 3. Temporary directory for downloads : D:\php5\tmp 4. Binaries directory : D:\php5 5. PHP code directory ($php_dir) : D:\php5\pear 6. Documentation directory : D:\php5\docs 7. Data directory : D:\php5\data 8. User-modifiable configuration files directory : D:\php5\cfg 9. Public Web Files directory : D:\php5\www 10. Tests directory : D:\php5\tests 11. Name of configuration file : C:\Windows\pear.ini 12. Path to CLI php.exe : D:\php5 1-12, 'all' or Enter to continue:
直接回車使用默認(rèn)值然后繼續(xù)安裝。本來以為萬事大吉的,可是偏偏在這里出現(xiàn)了錯(cuò)誤:
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘UTC' for '8.0/no DST' instead in phar://D:/php5/go-pear.phar/PEAR/Registry.php on line 1012
PEAR_Config::writeConfigFile fopen(‘C:\Windows\pear.ini','w') failed (fopen(C:\Windows\pear.ini): failed to open stream: Permission denied)
看樣子是沒有權(quán)限寫入C:\Windows\pear.ini,由于我使用的是Windows 7系統(tǒng),然后普通用戶打開的命令提示符,在這里當(dāng)然沒有權(quán)限寫入C:\Windows目錄了,看來要另辟蹊徑了?;氐絼偛臕re you installing a system-wide PEAR or a local copy?這段,為什么不選擇local copy呢?網(wǎng)上都是直接說默認(rèn)回車選擇system的,不想改寫C:\Windows目錄,于是我重新執(zhí)行php go-pear.phar,并且選擇local。
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] : local
Please confirm local copy by typing 'yes' : yes
好了,這下正常了:-)
Would you like to alter php.ini <D:\php5\php.ini>? [Y/n] :
然后就是上面這句,只有選擇Y同意修改php.ini。
php.ini <D:\php5\php.ini> include_path updated. Current include path : .;C:\php\pear Configured directory : D:\php5\pear Currently used php.ini (guess) : D:\php5\php.ini Press Enter to continue:
接著出現(xiàn)上面這段,看來沒有什么好改的,直接回車確認(rèn)即可。
到這里應(yīng)該能看到Thanks for using go-pear!這句了,那么恭喜你,PEAR總算是安裝成功了!
如何安裝PEAR Package包
接下來讓我們?nèi)EAR網(wǎng)站上看看有什么需要的吧。PEAR每個(gè)包都有安裝命令的提示,比如說MDB2這個(gè)包,上面已經(jīng)提示使用pear install MDB2命令安裝了,假設(shè)目錄還是D:\php5,那么我們利用下面的命令試試:
cd D:\php5
D:
pear install MDB2
結(jié)果出現(xiàn)下面這個(gè)錯(cuò)誤:
D:\php5>pear install MDB2 downloading MDB2-2.4.1.tgz ... Starting to download MDB2-2.4.1.tgz (119,790 bytes) ..........................done: 119,790 bytes ERROR: failed to mkdir C:\php\pear\docs\MDB2\docs\examples
無法創(chuàng)建目錄,看來又是權(quán)限問題,索性以管理員身份啟動(dòng)cmd命令提示符,然后重新執(zhí)行上面的命令。這次總算安裝成功了install ok!
另一個(gè)安裝報(bào)錯(cuò)案例:PHP pear安裝出現(xiàn) Warning: require_once(Structures/Graph.php)...錯(cuò)誤
在WINDOWS安裝pear,一路無阻很順利安裝完成,接著想安裝下pear email包來玩下,但接下來卻報(bào):
Warning: require_once(Structures/Graph.php): failed to open stream: No such file
or directory in PEAR\Downloader.php on line 1217
PHP Warning: require_once(Structures/Graph.php): failed to open stream: No such
file or directory in E:\Program Files\php5_3\pear\pear\PEAR\Downloader.php on l
ine 1217
新手沒辦法,網(wǎng)上找解決。折騰了老半天,還是報(bào)這錯(cuò)誤.原因很清楚就是少了Structures_Graph這個(gè)PEAR應(yīng)用,相直接通用pear命令:
pear install Structures_Graph-1.1.1
在線安裝這個(gè)應(yīng)用,但讓人痛心的是竟然也報(bào)同樣的錯(cuò)誤,我丟。。
不跟它玩了直接到PEAR官網(wǎng)下載Structures_Graph-1.1.0.tgz包。解壓看看里面的結(jié)構(gòu);發(fā)現(xiàn)里面正好有一個(gè)Structures/Graph.php;于是解壓并把壓縮包里的Structures文件夾放到pear根目下面。接著再運(yùn)行Structures_Graph的安裝命令,驚喜!!成功了。
接著再安裝email,不出意外也成功。到此這個(gè)糾結(jié)了我半天的問題終于解決了。
謝謝大家的閱讀哦!
相關(guān)文章
什么是PEAR?什么是PECL?PHP中兩個(gè)容易混淆的概念解釋
這篇文章主要介紹了什么是PEAR?什么是PECL?PHP中兩個(gè)容易混淆的概念解釋,本文用簡(jiǎn)潔的語言解釋了 它們的不同之處,需要的朋友可以參考下2015-07-07PHP使用CURL實(shí)現(xiàn)對(duì)帶有驗(yàn)證碼的網(wǎng)站進(jìn)行模擬登錄的方法
這篇文章主要介紹了PHP使用CURL實(shí)現(xiàn)對(duì)帶有驗(yàn)證碼的網(wǎng)站進(jìn)行模擬登錄的方法,可以幫助讀者加深對(duì)CURL操作的理解與應(yīng)用,需要的朋友可以參考下2014-07-07php將mysql數(shù)據(jù)庫整庫導(dǎo)出生成sql文件的具體實(shí)現(xiàn)
下面是php將mysql數(shù)據(jù)庫整庫導(dǎo)出生成sql文件的詳細(xì)代碼,希望對(duì)大家在用php編程時(shí)備份數(shù)據(jù)有一定幫助2014-01-01PHP實(shí)現(xiàn)mysqli批量執(zhí)行多條語句的方法示例
這篇文章主要介紹了PHP實(shí)現(xiàn)mysqli批量執(zhí)行多條語句的方法,結(jié)合實(shí)例形式分析了php連接mysqli并批量執(zhí)行多條語句的相關(guān)操作技巧,需要的朋友可以參考下2017-07-07php實(shí)現(xiàn)的美國(guó)50個(gè)州選擇列表實(shí)例
這篇文章主要介紹了php實(shí)現(xiàn)的美國(guó)50個(gè)州選擇列表實(shí)例,可實(shí)現(xiàn)讓當(dāng)前州為選中狀態(tài)的功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04