Try to install and configure PHP PEAR in Windows environment

WBOY
Release: 2016-07-29 09:14:44
Original
810 people have browsed it
What is PEARFrom BaiduEncyclopedia: PEAR is the abbreviation of the PHP Extension and Application Repository. It is a code repository for PHP extensions and applications. Simply put, PEAR is to PHP like CPAN (Comprehensive Perl Archive Network) to Perl. It can be seen that PEAR is a warehouse of PHP code. You can find a lot of useful code here to avoid us from repeatedly writing some functions. However, the PEAR code package is not downloaded directly through the HTTP website. We need to install PEAR. How to obtain and install PEARRecommendation: The following operations are completed in the Windows 7 environment, and are also applicable to Windows XP/2003/Vista/2008 systems. Some operations are tentative, in order to avoid detours , it is recommended to read this article first, and then perform related operations. If PEAR is not included in the PHP directory, that is, the go-pear.php file cannot be found, then we need to manually download the go-pear.php file. Click here to download and save this file as go-pear.php. Place it in the PHP installation directory where php.exe is located. My installation directory is D:php5 (this directory shall prevail below), then the location of go-pear.php should be D:php5go-pear.php. Start – Run, enter cmd, start the command prompt, enter the following command, mainly switch to the go-pear.php directory, and then execute this PHP script file:
1 2 3 cd D:\php5 D: php go-pear.php
Unfortunately, maybe because my PHP version is too new, the above operation prompt fails. The specific information is as follows: Deprecated: Assigning the return value of new by reference is deprecated in D:php5go-pear.php on line 733Sorry! 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 cooperation and sorry for the inconvenience!It means asking us to download go- at http://pear.php.net/go-pear.phar pear.phar file, then replace go-pear.php and try again. Download the go-pear.phar file and put it in the D:php5 folder, execute the following command:
1 2 3 cd D:\php5 D: php go-pear.phar
This time the following appears:
1 2 Are you installing a system-wide PEAR or a local copy?(system|local)[system]:
Press enter to default system and continue. The following are the default settings for pear's temporary, data, configuration, test, and execution directories:
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:\php52. Temporary directory for processing : D:\php5\tmp3. Temporary directory for downloads : D:\php5\tmp4. Binaries directory : D:\php55. PHP code directory ($php_dir): D:\php5\pear6. Documentation directory : D:\php5\docs7. Data directory : D:\php5\data8. User-modifiable configuration files directory : D:\php5\cfg9. Public Web Files directory : D:\php5\www10. Tests directory : D:\php5\tests11. Name of configuration file : C:\Windows\pear.ini12. Path to CLI php.exe : D:\php5   1-12, 'all' or Enter tocontinue:
直接回车使用默认值然后继续安装。本来以为万事大吉的,可是偏偏在这里出现了错误: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 tocontinue:
接着出现上面这段,看来没有什么好改的,直接回车确认即可。到这里应该能看到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网站吧。

以上就介绍了Windows环境下尝试安装并配置PHP PEAR,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template