PHP pear安装

Posted on 2012-07-06 10:19 bug yang 阅读(5787) 评论(0) 编辑 收藏

转自:http://wangye.org/blog/archives/266/

什么是PEAR

来自百度百科:PEAR是PHP扩展与应用库(the PHP Extension and Application Repository)的缩写。它是一个PHP扩展及应用的一个代码仓库,简单地说,PEAR之于PHP就像是CPAN(Comprehensive Perl Archive Network)之于Perl。

由此可见PEAR是PHP代码的仓库,在这里可以找到很多有用的代码,避免我们重复写一些功能,但是PEAR代码包并不是直接通过HTTP网站下载的,我们需要安装PEAR。

如何获取并安装PEAR

建议:下面操作在Windows 7环境下完成,同样适用于Windows XP/2003/Vista/2008系统,部分操作带有尝试性,为了避免弯路,建议先看完本文,然后再进行相关操作。

如果PHP目录下没有自带PEAR,即找不到go-pear.php文件,那么就需要我们手动下载go-pear.php文件,点击这里下载并另存为go-pear.php,这个文件放到php.exe所在的PHP安装目录下,我这里安装目录是D:\php5(下文以此目录为准),那么go-pear.php的位置应该是D:\php5\go-pear.php。

开始 – 运行,输入cmd,启动命令提示符,输入以下命令,主要是切换到go-pear.php目录下,然后执行这个PHP脚本文件:

1
2
3
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文件夹中,执行下面的命令:

1
2
3
cd D:\php5
D:
php go-pear.phar

这时出现:

1
2
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :

按回车默认system然后继续。以下是默认的pear的临时、数据、配置、测试、执行目录的设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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:

直接回车使用默认值然后继续安装。本来以为万事大吉的,可是偏偏在这里出现了错误:

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)

看样子是没有权限写入C:\Windows\pear.ini,由于我使用的是Windows 7系统,然后普通用户打开的命令提示符,在这里当然没有权限写入C:\Windows目录了,看来要另辟蹊径了。回到刚才Are you installing a system-wide PEAR or a local copy?这段,为什么不选择local copy呢?网上都是直接说默认回车选择system的,不想改写C:\Windows目录,于是我重新执行php go-pear.phar,并且选择local。

1
2
3
Are you installing a system-wide PEAR or a local copy?
(system|local) [system] : local
Please confirm local copy by typing 'yes' : yes

好了,这下正常了:-)

1
Would you like to alter php.ini <D:\php5\php.ini>? [Y/n] :

然后就是上面这句,只有选择Y同意修改php.ini。

1
2
3
4
5
6
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:

接着出现上面这段,看来没有什么好改的,直接回车确认即可。

到这里应该能看到Thanks for using go-pear!这句了,那么恭喜你,PEAR总算是安装成功了!

如何安装PEAR Package包

接下来让我们去PEAR网站上看看有什么需要的吧。PEAR每个包都有安装命令的提示,比如说MDB2这个包,上面已经提示使用pear install MDB2命令安装了,假设目录还是D:\php5,那么我们利用下面的命令试试:

1
2
3
cd D:\php5
D:
pear install MDB2

结果出现下面这个错误:

1
2
3
4
5
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

无法创建目录,看来又是权限问题,索性以管理员身份启动cmd命令提示符,然后重新执行上面的命令。这次总算安装成功了install ok!

好了,关于PEAR我就介绍到这儿了,更多的用法还是参考PEAR网站

PHP pear安装的更多相关文章

  1. [php-pear]如何使用 PHP-PEAR安装器,以及使用 PEAR 安装扩展库

    我们都知道 PHP PEAR,就是 PHP Extension and Application Respository,也就是 PHP 扩展和应用代码库. PHP 也可以通过 PEAR 安装器来进行 ...

  2. 【转】PEAR安装、管理及使用

    PEAR安装   linux下只要你安装的是PHP 4.3.0以上的版本,默认安装都是支持PEAR的,除非你使用了”--WITHOUT-PEAR”选项,修改PHP.INI文件,在INCLUDE_PAT ...

  3. PEAR安装

    看到PEAR章节,提到安装PEAR需要go-pear.bat,我机器上的PHP(v7.0.8)目录下,并没有go-pear.bat这个文件,网上查了一遍,怎么说的都有,最后还是在官网上找到解决方案. ...

  4. PHP pear安装出现 Warning: require_once(Structures/Graph.php)...错误

    今天在WINDOWS安装pear,一路无阻很顺利安装完成,接着想安装下pear email包来玩下,但接下来却报: Warning: require_once(Structures/Graph.php ...

  5. xampp 通过pear安装PHP_UML

    1.在环境变量中添加D:\xampp\php   // 如果前面已经有其他环境变量了,那么要用分号;跟前面的隔开 2.ctrl+R , cmd , pear install PHP_UML 3.如果提 ...

  6. windos下安装PEAR 注意

    1.在这里下载PEAR http://pear.php.net/go-pear.phar 在页面右键另存为 go-pear.phar 到PHP的根目录,并去目录查看是否保存为了go-pear.phar ...

  7. [转]pear windows 安装

    FROM : http://jingyan.baidu.com/article/ca41422fd8cf3d1eae99ed3e.html 因为想使用phpdocument生成文档,不得不安装pear ...

  8. 在WINDOWS下安装PEAR

    一.从官网下载go-pear.phar 文件,地址http://pear.php.net/go-pear.phar 将下载好的文件go-pear.phar 放到PHP安装目录下,dos 命令下进入PH ...

  9. 安装最新版本的PHPUnit后,不能使用

    我使用的是widows系统.本来3.7.8版本的Phpunit用的是非常顺畅的,最近重新安装phpunit,安装了最小版本,然后在使用的时候就会报很多各种错误.无奈之下只能降版本到3.7.8 首先要卸 ...

随机推荐

  1. Java Hour 10

    有句名言,叫做10000小时成为某一个领域的专家.姑且不辩论这句话是否正确,让我们到达10000小时的时候再回头来看吧. 本文作者Java 现经验约为10 Hour,请各位不吝赐教. Hour 10 ...

  2. oracle的关闭过程(各个模式关闭)

    关闭数据库与实例 与数据库启动一下,关闭数据库与实例也分为3步:关闭数据库-->实例卸载数据库--->终止实例. 1.Nomal(正常关闭方式) 命令:shutdown nomal 讲解: ...

  3. Libsvm自定义核函数【转】

    1. 使用libsvm工具箱时,可以指定使用工具箱自带的一些核函数(-t参数),主要有: -t kernel_type : set type of kernel function (default 2 ...

  4. Ninja - chromium核心构建工具

    转自:http://guiquanz.me/2014/07/28/a_intro_to_Ninja/ Ninja - chromium核心构建工具Jul 28, 2014 [在线编辑] 缘由 经过上次 ...

  5. CodeChef DISTNUM2 Easy Queries 节点数组线段树

    Description You are given an array A consisting of N positive integers. You have to answer Q queries ...

  6. loj 1034(最小点基)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25911 思路:强连通缩点,在新图中找入度为0的点的个数即可. #i ...

  7. java_final关键字的使用

    final : 最终.作为一个修饰符,1,可以修饰类,函数,变量.2,被final修饰的类不可以被继承.为了避免被继承,被子类复写功能.3,被final修饰的方法不可以被复写.4,被final修饰的变 ...

  8. SU unif2命令学习

  9. javascript优化--06模式(对象)01

    命名空间: 优点:可以解决命名混乱和第三方冲突: 缺点:长嵌套导致更长的查询时间:更多的字符: 通用命名空间函数: var MYAPP = MYAPP || {}; MYAPP.namespace = ...

  10. 贪心 POJ 1328 Radar Installation

    题目地址:http://poj.org/problem?id=1328 /* 贪心 (转载)题意:有一条海岸线,在海岸线上方是大海,海中有一些岛屿, 这些岛的位置已知,海岸线上有雷达,雷达的覆盖半径知 ...