views:

4002

answers:

4

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.

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.

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:

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.

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:

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:

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:

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.

+3  A: 

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!

Alan Storm
I'm getting "command not found". Did I skip a step?
Andrew
What happens when you type '/usr/local/bin/pear'?
Alan Storm
It would be great if you could add your php.ini include_path syntax. I've gotten this sorta working, but am still having some issues with includes breaking.
bryan kennedy
A: 

I am seeing the "command not found" on my shell... after running the pear install. Below is what I did, what am I doing wrong?? Please help

$ sudo 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 following optional PEAR packages: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2.

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

HTTP proxy (http://user:[email protected]:port), or Enter for none::

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 prefix ($prefix) : /Users/cathleen/Downloads
  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

1-7, 'all' or Enter to continue: 1 Installation prefix ($prefix) : /usr/local

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 prefix ($prefix) : /usr/local
  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

1-7, 'all' or Enter to continue:

The following PEAR packages are bundled with PHP: PEAR_Frontend_Web-beta, PEAR_Frontend_Gtk2, MDB2. Would you like to install these as well? [Y/n] : Y

Loading zlib: ok

Bootstrapping Installer...................

Bootstrapping PEAR.php............(remote) ok

Bootstrapping Archive/Tar.php............(remote) ok

Bootstrapping Console/Getopt.php............(remote) ok

Extracting installer..................

Downloading package: PEAR.............ok

Downloading package: Structures_Graph....ok

Preparing installer..................

Updating channel "doc.php.net"

Channel "doc.php.net" is up to date

Updating channel "pear.php.net"

Channel "pear.php.net" is up to date

Updating channel "pecl.php.net"

Channel "pecl.php.net" is up to date

Installing selected packages..................

Downloading and installing package: PEAR.............downloading PEAR-1.8.1.tgz ...

Starting to download PEAR-1.8.1.tgz (290,382 bytes)

............................................................done: 290,382 bytes

Could not delete /usr/local/bin/pear, cannot rename /usr/local/bin/.tmppear ERROR: commit failed

Package: Structures_Graph-stable.................. already installed ... ok

Package: Archive_Tar-stable....................... already installed ... ok

Package: Console_Getopt-stable.................... already installed ... ok

Package: PEAR_Frontend_Web-beta................... already installed ... ok

Downloading and installing package: PEAR_Frontend_Gtk2.......pear/PEAR_Frontend_Gtk2 requires PHP extension "php-gtk" (version >= 2.0.0dev)

pear/Gtk2_EntryDialog requires PHP extension "php-gtk" (version >= 2.0.0dev)

pear/Gtk2_FileDrop requires PHP extension "php-gtk" (version >= 2.0.0dev) No valid packages found

Package: MDB2..................................... already installed ... ok


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

php.ini include_path updated.

Current include path : .:/usr/local/bin/PEAR

Configured directory : /usr/local/PEAR

Currently used php.ini (guess) : /private/etc/php.ini

Press Enter to continue:

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

$ pear

-bash: pear: command not found

$ /usr/local/bin/pear

-bash: /usr/local/bin/pear: is a directory

what is going wrong? my PATH is set correctly. PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

I see a "PEAR" directory under /usr/local/bin but no pear and what's in PEAR are these:

$ ls /usr/local/PEAR/

Archive Console MDB2.php PEAR data tests Config HTML MIME Structures docs Config.php MDB2 OS XML pearfrontendweb.php

Please help!

A: 

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

:-)

A: 

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