pear 的安装

PEAR的安装
作者: EastSon

go-pear.org
go-pear.org是一个WEB站点,这个站点很特殊,里面就只有一个文件,只一个单独的PHP脚本,你可以下载并且执行它。这个文件将执行最近的稳定发行包。go-pear是交互平台,可以让你你在你的服务器上面用命令行来获得PEAR
PHP发行包里面有一个特殊的PEAR安装包,另一方面go-pear提供了一个最新稳定版的PEAR发行包。当然go-pear不知道你的目录结构,便可以计算出,来完成PEAR的安装过程。

前提:
因为go-pear是用PHP写的一个脚本,因此你必须在服务器上有一个PHP CGICLI程序来执行这个脚本。默认情况下CLI程序已经随着PHP模块安装了。试着运行php v 来看一下是否可用:

PHP 5.0.0 (cli), Copyright (c) 1997-2004 The PHP GroupZend Engine v2.0, Copyright (c) 1998-2004 Zend Technologies

注:在我的Windows平台上PHP5.1.6上面要使用php –v 来执行这个命令,下面有好多命令一样。
默认情况下php命令行程序在UNIX下安装于 /usr/local/bin Windows下安装于 C:\php 。在WindowsPHPCLI版程序也许叫做php-cli


得到PEAR
如果你的PHP安装包没有包含PEAR,你可以使用go-pear做为通程序来获得PEAR。前提是你需要一个已安装的GLICGI版本的PHP
你可以下载go-pear脚本并且执行它,像下面这样在命令行中执行:
$lynx source http://go-pear.org | php
这个脚本从http://go-pear.org获得脚本内容,并由PHP来执行。
如果你的系统上lynx无效,可以用其它的方法来直接获得go-pear:
$wget O- http://go-pear.org | php 使用GNUS wget
fetch o http://go-pear.org |php 使用fetchFreeBSD
GET http:/go-pear.org | php 使用Perl LWPGET工具。
Windows平台,你可以使用PHPURL流来获得,这个要求url_incluesphp.ini中没有被禁用。
C:\>php-cli r “include(‘http://go-pear.org’);”
还有一种就是直接用浏览器打开http://go-pear.org,把首页另存为go-pear.php然后在命令行中运行。
C:\php 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 PEAR packages bundled


with PHP: DB, Net_Socket, Net_SMTP, Mail, XML_Parser, PHPUnit.


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

注:在我的php5.1.6环境中,有一个c:\php下有go-pear.bat 我直接运行,出现选择systemlocal直接回车就行了。
按回车继续,出现下面的信息:

HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:

输入代理信息,如果直接上网,直接按回车就行了。
如果设置了HTTP代码环境,go-pear将检查你的http_proxy环境变量,并使用你指定的HTTPproxy来下载PEAR包,如果不是,只需要直接回车就可以了。
现在,到了最关键的地方:

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 then, or simply press Enter toaccept these locations.
1.  Installation prefix          :/usr/local
2. Binaries directory : $prefix/bin
3. PHP code directory : $prefix/share/pear
4.  Documentation base directory : $php_dir/docs
5.  Data base directory          : $php_dir/data
6.  Tests base directory         : $php_dir/tests1-
6, ‘all’ or Enter to continue:

每一个设置都会设定一个值(prefix,bin_dir,php_dir,doc_dir,data_dir,test_dir )
下面是这些设置的说明:
Installation prefix 你安装PEAR的根目录。下面的五个选项将使用它作为根目录。
Binaries directory. 程序和PEAR包中PHP脚本安装的地方。pear 将在这里执行。记得要把这个路径加到人的PATH环境中去。
PHP code directory   PHP代码安装位置。这个路径必须在php.ini include_path中包含。
Documentation base directory 文档的基本目录。,默认情况下是$php_dir/doc,每一个包的文档做为$doc_dr/Package/file来安装。
Database directory    PEAR安装程序保存数据文件的地方。
Tests base directory 包旧的测试脚本安装的地方。包的名字也添加到这个路径。

当设置完这些路径,按回车确定:

The following PEAR packages are bundled with PHP: DB, Net_Socket, Net_SMTP,Mail, XML_Parser, PHPUnit2.Would you like to install these as well? [Y/n] :

根据配置,go-paer决定在哪里安装包,直接按回车继续:

Loading zlib: ok
Downloading package: PEAR………….ok
Downloading package: Archive_Tar……ok
Downloading package: Console_Getopt….ok
Downloading package: XML_RPC……….ok
Bootstrapping: PEAR……………….(remote) ok
Bootstrapping: Archive_Tar…………(remote) ok
Bootstrapping: Console_Getopt………(remote) ok
Downloading package: DB……………ok
Downloading package: Net_Socket…….ok
Downloading package: Net_SMTP………ok
Downloading package: Mail………….ok
Downloading package: XML_Parser…….ok
Downloading package: PHPUnit2………ok
Extracting installer………………ok
install ok:
PEAR 1.3.1install ok:
Archive_Tar 1.2install ok:
Console_Getopt 1.2install ok:
XML_RPC 1.1.0install ok:
DB 1.6.4install ok:
Net_Socket 1.0.2install ok:
Net_SMTP 1.2.6install ok:
Mail 1.1.3install ok:
XML_Parser 1.2.0install ok:
PHPUnit2 2.0.0beta2 The ‘pear’ command is now at your service at /usr/local/bin/pear

至此PEAR也就安装成功

说明一下:我自己用的是Windows系统,PHP是5.1.6
在我的PHP目录下只有一个go-pear.bat,还有一个PEAR目录,里面有一个go-pear.phar(这个应该是就是书上说的go-pear.php)
我用php C:/php/pear/go-pear.phar,倒还真执行了,
其实直接执行go-pear.bat
会出选择system或local,这个好像是为了让选择PEAR的安装配置,好像是可以装多个
直接回车后就到配置PEAR的环境的地方了,估计这里是做一下确认吧
我的确认后就直接开始安装了
但安装完后DB,XML_parser等都没装上去

我是自己招待命令 pear install DB命令安装上去的

安装成功后会在C:/php目录下产生一个pear.bat,这个文件就是pear程序,好多操作都要通过这个程序来完成。

另外就是要修改php.ini中的include_path!1!!!!

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

购物车