How Do I Install PHP CLI on Mac OS X?

6

I'm running Mac OSX 10.8.2. I'm also quite new to Mac OSX -- previously the only Mac I understood was the Classic Mac. My other workstations are Windows and Linux.

What's the technique to install PHP CLI on Mac OSX? See, I use gedit for Mac and connect to either an FTP location or to my local Ubuntu Linux Server in a VM. In that editor, there's a feature where I can add an external program, and a technique I usually use is to add "php -l", which lets me take the current document and lint check it against PHP CLI. I used to do this all the time on Ubuntu, but on the Mac I'm not certain how to install PHP CLI.

Volomike

Posted 2013-01-13T02:32:05.420

Reputation: 691

Answers

7

It should already be present. Typing php --version from a command line on a Mac OS X 10.8 install, i get:

merak:~ peelman$ php --version
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

If you need other utilities, you should look at the Homebrew project.

peelman

Posted 2013-01-13T02:32:05.420

Reputation: 4 580

1Well I'll be dipped in.... Awesome! Thanks! :) – Volomike – 2013-01-15T03:52:02.053

0

You can also have a look at http://php-osx.liip.ch for an installer of the latest PHP versions for OS-X.

heiglandreas

Posted 2013-01-13T02:32:05.420

Reputation: 1 153

0

Check this link if you want to enable php-cli on MAMP. It worked for me pretty clean :)

The answer that worked for me :-

I had the same problem. Running MAMP on OS X Leopard Server. You need to point the system path to the MAMP php whereas now it's trying to use the default OS X install version issuing the command 'which php' at this point should show '/usr/bin/php' but we want this to point to our MAMP version instead

In terminal issue the following commands. This will rename the current OS X php to php-old, then create a new symbolic link (NOT an alias!) to the MAMP php version...

sudo mv /usr/bin/php usr/bin/php-old sudo ln -s /Applications/MAMP/bin/php5.3/bin/php usr/bin/php

which php *should now output /Applications/MAMP/bin/php5.3/bin/ You can now issue 'php -v' and you should see some output about the 5.3 version of php. Now the Kaltura install should see that php-cli is running.

If that does not work however, you can also update the php PATH in your user .profile with the following command: export PATH=/Applications/MAMP/bin/php5.3/bin:$PATH

which php *should now output /Applications/MAMP/bin/php5.3/bin/

ilight

Posted 2013-01-13T02:32:05.420

Reputation: 216