How to set up PEAR on Mac OS X 10.5 Leopard

江枫思渺然 提交于 2019-11-28 20:50:13

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).

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.

So, we need to make sure that

  1. The php.ini file for your website has the PEAR directory in its include path
  2. The php.ini file for your command line php application has the PEAR directory in its include path
  3. Your shell application (terminal, likely BASH in you're on OS X) has the PEAR directory in its include path

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

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).

For number 2, run the following from your command line

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).

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

** 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

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

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

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

$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

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!

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

:-)

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

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

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

include_path=".:/path_to_pear_dir/PEAR"

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

;***** Added by go-pear
include_path=".:/usr/local/bin/PEAR"
;*****
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!