大爺最近在台北的圖書館借了一本PHP PEAR(註1)的書
要來好好的研究一下PHP PEAR到底是在搞什麼鬼 ^^"
好啦…就讓我們好好的照著書上的指令裝一下PEAR
步驟1:先安裝lynx
# sudo apt-get install lynx
(老實說我也不太清楚lynx這個套件是做什麼用的…等有空再來好好研究好了 ^^")
步驟2:安裝PEAR的基本套件,記得要用root帳號來安裝啊…不然之後可能會出錯 @@
# lynx -source http://pear.php.net/go-pear | php
(書上的網址比較舊,官方網站已經改成這個網址了)
接著就會出現下面的提示畫面:
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:password@proxy.myhost.com:port), or Enter for none::
(這個最主要是要讓用戶設定proxy上網之類的,大爺沒有proxy,所以就直接按Enter跳過唄)
再來出現的是:
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.
(下面是一個建議的檔案版面用來安裝你新的PEAR。要改變個別的位址,請輸入目錄前面的號碼。
輸入all來改變全部或簡單的輸入Enter來保持預設的位址。)
1. Installation prefix ($prefix) : /home/ckwsteven
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:
接下來是:
The following PEAR packages are bundled with PHP: PEAR_Frontend_Web-beta,
PEAR_Frontend_Gtk2, MDB2.
Would you like to install these as well? [Y/n] : y
(下面的套件和php綁在一起:包含PEAR_Frontend_Web-beta,PEAR_Frontend_Gtk2, MDB2。
你也要一起安裝嗎,我是選Y啦 ^^)
再來就是一連串的安裝啦…
Loading zlib: ok
Bootstrapping Installer...................
Bootstrapping PEAR.php............(remote) ok
Bootstrapping Archive/Tar.php............(remote) ok
Bootstrapping Console/Getopt.php............(remote) ok
Extracting installer..................
Downloading package: PEAR.............ok
Downloading package: Structures_Graph....ok
Preparing installer..................
Updating channel "doc.php.net"
Update of Channel "doc.php.net" succeeded
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
Installing selected packages..................
Downloading and installing package: PEAR.............warning: pear/PEAR requires package "pear/Archive_Tar" (recommended version 1.3.3)
warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.2)
warning: pear/PEAR requires package "pear/Console_Getopt" (recommended version 1.2.3)
warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
downloading PEAR-1.9.0.tgz ...
Starting to download PEAR-1.9.0.tgz (291,634 bytes)
.............(很長…其它的很多就不po了@@)
出現問題了!!
******************************************************************************
WARNING! The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
</var/www/bailing/lib/pear/PEAR>
If the specified directory is also not in the include_path used by
your scripts, you will have problems getting any PEAR packages working.
Would you like to alter php.ini </etc/php5/cli/php.ini>? [Y/n] :
(因為大爺有更改了預設的路徑,所以這邊是問大爺要不要更改php.ini設定…當然是要囉!!)
php.ini </etc/php5/cli/php.ini> include_path updated.
Current include path : .:/etc/pear/PEAR
Configured directory : /var/www/bailing/lib/pear/PEAR
Currently used php.ini (guess) : /etc/php5/cli/php.ini
Press Enter to continue:
(這裡就照它預設的試試看唄 ^^")
The 'pear' command is now at your service at /var/www/bailing/lib/pear/bin/pear
** The 'pear' command is not currently in your PATH, so you need to
** use '/var/www/bailing/lib/pear/bin/pear' until you have added
** '/var/www/bailing/lib/pear/bin' to your PATH environment variable.
Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.
For more information about PEAR, see:
http://pear.php.net/faq.php
http://pear.php.net/manual/
Thanks for using go-pear!
(到這裡就安裝完畢了,可以使用'pear list'指令來看看有那些套件已經被安裝了)
輸入命令:#pear list
會出現:
The program 'pear' is currently not installed. You can install it by typing:
apt-get install php-pear
pear: command not found
因為大爺有改過安裝的地方,所以得把pear安裝的位址加入環境變數或是輸入一連串的位址
這裡改成輸入 #/var/www/bailing/lib/pear/bin/pear list
或是指定pear路徑給環境變數PATH: #PATH="$PATH":/var/www/bailing/lib/pear/bin/
這樣子一來就能直接輸入pear list了。
輸入pear list之後會顯示:
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.7 stable
Config 1.10.11 stable
Console_Getopt 1.2.3 stable
HTML_Template_IT 1.3.0 stable
MDB2 2.4.1 stable
MIME_Type 1.2.0 stable
PEAR 1.9.0 stable
PEAR_Frontend_Web 0.7.4 beta
Structures_Graph 1.0.3 stable
有了!!…到這裡應該就安裝完成了吧,下一回大爺再來好好試試PEAR所提供的功能吧 ^^
註1:PHP PEAR嚴選程式庫 林孟偉 著 旗標出版社
留言列表