João Paulo Cercal

Staff Security Engineer at LastPass

  • PHP

Installing PEAR on OSX 10.8 Mountain Lion

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

Read this article in

Folks, this time we’ll learn to install PEAR on Apple’s operating system. This guide should also be compatible with earlier operating systems in the apple family, such as Snow Leopard and Lion.

Well, let’s share the recipe.

Open the Terminal and check whether PEAR is already installed with the following command.

1
$ pear version

If it isn’t installed, the command’s output should look like:

1
pear: command not found

If you saw the message above, then we can install pear, because it isn’t on your operating system.

Run the following command to select a directory and download the pear installation package:

1
2
$ cd /usr/local
$ curl -O  http://pear.php.net/go-pear.phar

Finally, let’s install pear:

1
$ sudo php -d detect_unicode=0 go-pear.phar

Just check the specified PATH, if you need to customize your installation, make the necessary changes, in my case I didn’t change a single line and pressed ENTER straight away.

The Script will also ask whether you want to update the include_path of PHP by adding PEAR, press Y (Yes) followed by ENTER.

Now let’s add PEAR to your user’s PATH.

Type the following commands in the Terminal.

1
2
$ cd
$ vi .bashrc

Add the following line immediately after the last path in the PATH variable:

/Users/nome-do-seu-usuario/pear/bin/

Save the file and run the following command in the Terminal:

1
2
$ source .bashrc
$ pear version

You should see something like the output shown below:

1
2
3
PEAR Version: 1.9.4
PHP Version: 5.3.15
Zend Engine Version: 2.3.0

If you saw the output above, then PEAR was installed successfully on your machine. Otherwise, check the commands mentioned above again and see whether there was a syntax error.

If you’re having trouble installing pear or manage to install it through this guide, please leave your comment.