如何在Mac OS X 10.5 Leopard上设置PEAR

时间:2021-10-16 20:40:56

I'm ultimately trying to install PEAR so I can easily install PHPUnit. I want to set up a Mac, Apache, MySQL, PHP, PHPUnit development environment so I can test locally. I already have Apach, MySQL and PHP working. Now all I need is PHPUnit, which means I need PEAR to install it.

我最终尝试安装PEAR,因此我可以轻松安装PHPUnit。我想建立一个Mac,Apache,MySQL,PHP,PHPUnit开发环境,以便我可以在本地进行测试。我已经有Apach,MySQL和PHP工作了。现在我只需要PHPUnit,这意味着我需要PEAR来安装它。

I have searched all over, and there are a few variations of "the tutorial" on how to install PEAR on Mac OS X 10.5. However, I can't seem to get any of them to work! Has anyone had success with this? I'm not totally confident that I have everything set up as it should be, so if you could include the "default" Mac OS X 10.5 include paths, or a simple explanation of where everything should go, I would appreciate it.

我已经搜索过了,有关如何在Mac OS X 10.5上安装PEAR的“教程”的一些变体。但是,我似乎无法让他们中的任何一个工作!有人有这个成功吗?我并不完全相信我已经设置了所有应有的东西,所以如果你可以包含“默认”Mac OS X 10.5包含路径,或者简单解释一切应该去哪里,我将不胜感激。

Following this tutorial I do the following:

按照本教程,我执行以下操作:

curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php

I press enter until I get to a list with 7 include paths:

我按下回车键直到找到包含7个包含路径的列表:

1. Installation prefix ($prefix) : /Users/andrew
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

I change the Installation prefix to be /usr/local, press enter to continue, type Y to also install PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2. Eventually, everything is installed.

我将安装前缀更改为/ usr / local,按Enter继续,键入Y以安装PEAR_Frontend_Web-beta,PEAR_Frontend_Gtk2,MDB2。最终,一切都安装好了。

Next...

On the first try, I think include_path was commented out of the php.ini file, but since I've already changed this line, and this is not the first time I've tried installing, I get the following message:

在第一次尝试时,我认为include_path是从php.ini文件中注释掉的,但由于我已经更改了这一行,并且这不是我第一次尝试安装,我收到以下消息:

WARNING!  The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
</usr/local/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 </private/etc/php.ini>? [Y/n] : 

I type Y and let pear automatically update my include path:

我输入Y并让pear自动更新我的包含路径:

php.ini </private/etc/php.ini> include_path updated.

Current include path           : .:/usr/share/pear
Configured directory           : /usr/local/PEAR
Currently used php.ini (guess) : /private/etc/php.ini

I press enter to continue, and get the following message:

我按Enter继续,并收到以下消息:

The 'pear' command is now at your service at /usr/local/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/local/bin/pear' until you have added
** '/usr/local/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!

PHP Warning:  rmdir(/usr/local/temp): Not a directory in /Users/andrew/go-pear.php on line 1237

Warning: rmdir(/usr/local/temp): Not a directory in /Users/andrew/go-pear.php on line 1237

Update: I think I know why these last two warnings came up. Previously, I tried to fix the temp directory problem by creating a symbolic link to /tmp but if I understand correctly, PEAR is trying to create its own temp directory for installation, then it's going to delete it when it's finished. So I should not have created this symbolic link since it's going to try to delete the temp directory when the installation has finished.

更新:我想我知道为什么最后两个警告出现了。以前,我尝试通过创建/ tmp的符号链接来修复临时目录问题,但如果我理解正确,PEAR正在尝试创建自己的临时目录进行安装,那么它将在完成后删除它。所以我不应该创建这个符号链接,因为它将在安装完成后尝试删除临时目录。

3 个解决方案

#1


There's a few things that could be going wrong here, these are only guesses.

这里有一些可能出错的事情,这些只是猜测。

First, there's two include paths you'll need to worry about. The first is your PHP include path. PEAR libraries are (mostly) just PHP code, specially packaged up. When you install a PEAR module you're downloading all the PHP code needed for that library, and any other PEAR libraries the library you're installing rely on (sorry about that sentence, but I'm not sure there's a better way to say that). This include path is set in your php.ini files (one file for your command line php, another for yoru web server php; often the same file).

首先,您需要担心的是两条包含路径。第一个是PHP包含路径。 PEAR库(大多数)只是PHP代码,特别打包。当您安装PEAR模块时,您正在下载该库所需的所有PHP代码,以及您正在安装的库所依赖的任何其他PEAR库(抱歉该句,但我不确定是否有更好的方法可以说那)。这包括路径在你的php.ini文件中设置(一个文件用于命令行php,另一个用于yoru web服务器php;通常是相同的文件)。

The second include path you'll need to worry about is your UNIX/shell include path. This is the path that your computer will search for commands in when you enter a command from a terminal. The 'pear' command is a command line command.

第二个包含您需要担心的路径是UNIX / shell包含路径。这是从终端输入命令时计算机将搜索命令的路径。 'pear'命令是一个命令行命令。

So, we need to make sure that

所以,我们需要确保这一点

  1. The php.ini file for your website has the PEAR directory in its include path
  2. 您网站的php.ini文件在其包含路径中包含PEAR目录

  3. The php.ini file for your command line php application has the PEAR directory in its include path
  4. 命令行php应用程序的php.ini文件在其include路径中有PEAR目录

  5. Your shell application (terminal, likely BASH in you're on OS X) has the PEAR directory in its include path
  6. 您的shell应用程序(终端,可能是您在OS X上的BASH)在其包含路径中具有PEAR目录

So, for number 1, put a PHP page on your server that include the function call

因此,对于数字1,在您的服务器上放置一个包含函数调用的PHP页面

phpinfo();

This will list a bunch of information about your server. Look for the location of php.ini. Open this file in a text editor, look for the include_path variable, and add the path to your PEAR directory (don't remove the other paths, just add yours).

这将列出有关您的服务器的大量信息。寻找php.ini的位置。在文本编辑器中打开此文件,查找include_path变量,并添加PEAR目录的路径(不要删除其他路径,只需添加您的路径)。

For number 2, run the following from your command line

对于数字2,从命令行运行以下命令

php -r "phpinfo();" | grep '.ini'

A bunch of lines will print out, look for the one that reads something like "Loaded Configuration File". Open this file in a text editor, look for the include_path variable, and add the path to your PEAR directory (don't remove the other paths, just add yours).

将打印出一堆行,查找读取“Loaded Configuration File”之类的行。在文本编辑器中打开此文件,查找include_path变量,并添加PEAR目录的路径(不要删除其他路径,只需添加您的路径)。

Finally, and this is what I think your problem is, we need to ensure that the pear command line command is in your shell/bash path. That's what this error is refering to

最后,这就是我认为你的问题,我们需要确保pear命令行命令在你的shell / bash路径中。这就是这个错误所指的内容

** The 'pear' command is not currently in your PATH, so you need to

There should be a file in your home directory named '.bash_profile'. It's a hidden file, so it won't showup in the Finder. Open it with a text editor. If you're having trouble because this is a hidden file, use the command line pico editor. Ctrl-X will save from pico

您的主目录中应该有一个名为“.bash_profile”的文件。它是一个隐藏文件,因此它不会在Finder中显示。用文本编辑器打开它。如果您遇到问题,因为这是一个隐藏文件,请使用命令行pico编辑器。 Ctrl-X将从pico中保存

cd ~
pico .bash_profile

This file gets executed by your shell everytime you open a terminal window. We're going to add /usr/local/bin to your PATH, which means when you attempt to run a command, yoru computer will search for the command in this folder. Add the following line to the bottom of .bash_profile

每次打开终端窗口时,shell都会执行此文件。我们要将/ usr / local / bin添加到PATH,这意味着当您尝试运行命令时,yoru计算机将在此文件夹中搜索该命令。将以下行添加到.bash_profile的底部

export PATH=/usr/local/bin:$PATH

This is, more or less, equivilant to the following PHP code

这或多或少与以下PHP代码等效

$PATH = '/usr/local/bin:'.$PATH

You're adding /usr/local/bin as the first colon-delimited place to look for command, and then adding the rest of the existing path to it. Once you've added that line, close your terminal, re-open it, and then type

您将/ usr / local / bin添加为查找命令的第一个以冒号分隔的位置,然后将其余的现有路径添加到其中。添加该行后,关闭终端,重新打开,然后键入

pear

This should give you a list of valid pear commands, but more importantly will let you know pear is in your path.

这应该给你一个有效的梨命令列表,但更重要的是让你知道梨在你的道路上。

Good luck!

#2


I figured it out. You "HAVE TO" run the go-pear.php at where you want pear installed, so you need to run it under /usr/local if you want pear binary to be installed under /usr/local/bin

我想到了。你“必须”在你想要安装pear的地方运行go-pear.php,所以你需要在/ usr / local下运行它,如果你想在/ usr / local / bin下安装pear二进制文件

:-)

#3


user "bryan kennedy" (above) wanted to know the syntax for the "include_path" change needed in "php.ini"

用户“bryan kennedy”(上图)想知道“php.ini”中所需的“include_path”更改的语法

(I had a similar problem to the OP and I just fixed the issue with the help of this post.)

(我对OP有类似的问题,我在这篇文章的帮助下解决了这个问题。)

the change to php.ini will look like...

对php.ini的更改看起来像......

include_path=".:/path_to_pear_dir/PEAR"

this is how it looks when you allow "go-pear.php" to make the change....

当你允许“go-pear.php”进行改变时,这就是它的样子....

;***** Added by go-pear
include_path=".:/usr/local/bin/PEAR"
;*****

#1


There's a few things that could be going wrong here, these are only guesses.

这里有一些可能出错的事情,这些只是猜测。

First, there's two include paths you'll need to worry about. The first is your PHP include path. PEAR libraries are (mostly) just PHP code, specially packaged up. When you install a PEAR module you're downloading all the PHP code needed for that library, and any other PEAR libraries the library you're installing rely on (sorry about that sentence, but I'm not sure there's a better way to say that). This include path is set in your php.ini files (one file for your command line php, another for yoru web server php; often the same file).

首先,您需要担心的是两条包含路径。第一个是PHP包含路径。 PEAR库(大多数)只是PHP代码,特别打包。当您安装PEAR模块时,您正在下载该库所需的所有PHP代码,以及您正在安装的库所依赖的任何其他PEAR库(抱歉该句,但我不确定是否有更好的方法可以说那)。这包括路径在你的php.ini文件中设置(一个文件用于命令行php,另一个用于yoru web服务器php;通常是相同的文件)。

The second include path you'll need to worry about is your UNIX/shell include path. This is the path that your computer will search for commands in when you enter a command from a terminal. The 'pear' command is a command line command.

第二个包含您需要担心的路径是UNIX / shell包含路径。这是从终端输入命令时计算机将搜索命令的路径。 'pear'命令是一个命令行命令。

So, we need to make sure that

所以,我们需要确保这一点

  1. The php.ini file for your website has the PEAR directory in its include path
  2. 您网站的php.ini文件在其包含路径中包含PEAR目录

  3. The php.ini file for your command line php application has the PEAR directory in its include path
  4. 命令行php应用程序的php.ini文件在其include路径中有PEAR目录

  5. Your shell application (terminal, likely BASH in you're on OS X) has the PEAR directory in its include path
  6. 您的shell应用程序(终端,可能是您在OS X上的BASH)在其包含路径中具有PEAR目录

So, for number 1, put a PHP page on your server that include the function call

因此,对于数字1,在您的服务器上放置一个包含函数调用的PHP页面

phpinfo();

This will list a bunch of information about your server. Look for the location of php.ini. Open this file in a text editor, look for the include_path variable, and add the path to your PEAR directory (don't remove the other paths, just add yours).

这将列出有关您的服务器的大量信息。寻找php.ini的位置。在文本编辑器中打开此文件,查找include_path变量,并添加PEAR目录的路径(不要删除其他路径,只需添加您的路径)。

For number 2, run the following from your command line

对于数字2,从命令行运行以下命令

php -r "phpinfo();" | grep '.ini'

A bunch of lines will print out, look for the one that reads something like "Loaded Configuration File". Open this file in a text editor, look for the include_path variable, and add the path to your PEAR directory (don't remove the other paths, just add yours).

将打印出一堆行,查找读取“Loaded Configuration File”之类的行。在文本编辑器中打开此文件,查找include_path变量,并添加PEAR目录的路径(不要删除其他路径,只需添加您的路径)。

Finally, and this is what I think your problem is, we need to ensure that the pear command line command is in your shell/bash path. That's what this error is refering to

最后,这就是我认为你的问题,我们需要确保pear命令行命令在你的shell / bash路径中。这就是这个错误所指的内容

** The 'pear' command is not currently in your PATH, so you need to

There should be a file in your home directory named '.bash_profile'. It's a hidden file, so it won't showup in the Finder. Open it with a text editor. If you're having trouble because this is a hidden file, use the command line pico editor. Ctrl-X will save from pico

您的主目录中应该有一个名为“.bash_profile”的文件。它是一个隐藏文件,因此它不会在Finder中显示。用文本编辑器打开它。如果您遇到问题,因为这是一个隐藏文件,请使用命令行pico编辑器。 Ctrl-X将从pico中保存

cd ~
pico .bash_profile

This file gets executed by your shell everytime you open a terminal window. We're going to add /usr/local/bin to your PATH, which means when you attempt to run a command, yoru computer will search for the command in this folder. Add the following line to the bottom of .bash_profile

每次打开终端窗口时,shell都会执行此文件。我们要将/ usr / local / bin添加到PATH,这意味着当您尝试运行命令时,yoru计算机将在此文件夹中搜索该命令。将以下行添加到.bash_profile的底部

export PATH=/usr/local/bin:$PATH

This is, more or less, equivilant to the following PHP code

这或多或少与以下PHP代码等效

$PATH = '/usr/local/bin:'.$PATH

You're adding /usr/local/bin as the first colon-delimited place to look for command, and then adding the rest of the existing path to it. Once you've added that line, close your terminal, re-open it, and then type

您将/ usr / local / bin添加为查找命令的第一个以冒号分隔的位置,然后将其余的现有路径添加到其中。添加该行后,关闭终端,重新打开,然后键入

pear

This should give you a list of valid pear commands, but more importantly will let you know pear is in your path.

这应该给你一个有效的梨命令列表,但更重要的是让你知道梨在你的道路上。

Good luck!

#2


I figured it out. You "HAVE TO" run the go-pear.php at where you want pear installed, so you need to run it under /usr/local if you want pear binary to be installed under /usr/local/bin

我想到了。你“必须”在你想要安装pear的地方运行go-pear.php,所以你需要在/ usr / local下运行它,如果你想在/ usr / local / bin下安装pear二进制文件

:-)

#3


user "bryan kennedy" (above) wanted to know the syntax for the "include_path" change needed in "php.ini"

用户“bryan kennedy”(上图)想知道“php.ini”中所需的“include_path”更改的语法

(I had a similar problem to the OP and I just fixed the issue with the help of this post.)

(我对OP有类似的问题,我在这篇文章的帮助下解决了这个问题。)

the change to php.ini will look like...

对php.ini的更改看起来像......

include_path=".:/path_to_pear_dir/PEAR"

this is how it looks when you allow "go-pear.php" to make the change....

当你允许“go-pear.php”进行改变时,这就是它的样子....

;***** Added by go-pear
include_path=".:/usr/local/bin/PEAR"
;*****