Jump to content



Photo

Running PHP on OSX

php osx mac apache cli

  • Please log in to reply
7 replies to this topic

#1 goodbytes

goodbytes

    Just below average Joe

  • Tech Issues Solved: 1
  • Joined: 07-May 04
  • Location: England

Posted 21 March 2013 - 20:28

I'm wanting to update the local version of PHP on my Mac.. i've been doing some digging and got a little confused.

If i run php -i from the terminal it says:

        $ php -i
        phpinfo()
        PHP Version => 5.3.15
        Configuration File (php.ini) Path => /etc
        Loaded Configuration File => (none)

I was sure i had 5.4 installed so ran phpinfo();

        PHP Version 5.4.5
        Loaded config file: /usr/local/php5/lib/php.ini

A problem i'm having is i can't seem to make any php.ini file work, i'm getting lots of

Notice: Undefined index:

errors, so error reporting is too high, but no matter how many php.ini files i find and edit it's not taking effect..

I have no idea which version of PHP is being used or why there is two.

Is it possible to disable or remove one of them so i know exactly whats going on, and then i can update it to a newer version?

Thanks


#2 pes2013

pes2013

    Neowinian

  • Joined: 24-September 12

Posted 21 March 2013 - 20:32

I'm wanting to update the local version of PHP on my Mac.. i've been doing some digging and got a little confused.

If i run php -i from the terminal it says:

		$ php -i
		phpinfo()
		PHP Version => 5.3.15
		Configuration File (php.ini) Path => /etc
		Loaded Configuration File => (none)

I was sure i had 5.4 installed so ran phpinfo();

		PHP Version 5.4.5
		Loaded config file: /usr/local/php5/lib/php.ini

A problem i'm having is i can't seem to make any php.ini file work, i'm getting lots of

Notice: Undefined index:

errors, so error reporting is too high, but no matter how many php.ini files i find and edit it's not taking effect..

I have no idea which version of PHP is being used or why there is two.

Is it possible to disable or remove one of them so i know exactly whats going on, and then i can update it to a newer version?

Thanks

What user are you running PHP as?

Tip: Look for PHP and Linux. Will give you much more results as OS X is basically unix (and Linux is basically unix)

#3 Mr.XXIV

Mr.XXIV

    Shine bright like Iron Man.

  • Tech Issues Solved: 1
  • Joined: 30-April 11
  • Location: Durham, North Carolina
  • OS: OS X Yosemite
  • Phone: iPhone 5s

Posted 21 March 2013 - 20:33

I've gone through the same problems too. I usually work with Homebrew to take care of getting the latest possible stables of PHP, MySQL and possibly even MongoDB. They can be a version behind sometimes.

I'd recommend working with Linux Ubuntu Server on a VirtualBox because you can do it all from scratch while having the internet bridged by using eth0 (Ethernet), I believe it won't work well through WiFi.

#4 OP goodbytes

goodbytes

    Just below average Joe

  • Tech Issues Solved: 1
  • Joined: 07-May 04
  • Location: England

Posted 21 March 2013 - 20:39

VirtualBox seems overkill for a little local development, OSX comes with PHP out of the box which i believe is the 5.3 instance... as far as a bit of coding goes it works fine as is, i can add error_reporting(E_ALL ^ E_NOTICE) to remove the undefined index notices.. but yeah, would like to try a newer version if possible.

Not sure what you mean by what is it running as? I just installed the 5.4 binary i believe? not sure about 5.3?

#5 virtorio

virtorio

    Neowinian Senior

  • Tech Issues Solved: 15
  • Joined: 28-April 03
  • Location: New Zealand
  • OS: OSX 10.10, Windows 8.1
  • Phone: LG G3

Posted 21 March 2013 - 20:43

I've never touched the PHP version OSX comes with, I use MAMP - http://www.mamp.info/en/index.html

#6 Brian M.

Brian M.

    Neowinian Senior

  • Tech Issues Solved: 11
  • Joined: 07-January 05
  • Location: London, UK

Posted 22 March 2013 - 09:29

I've never touched the PHP version OSX comes with, I use MAMP - http://www.mamp.info/en/index.html


There is also XAMPP - http://www.apachefri...g/en/xampp.html

#7 The Protagonist

The Protagonist

    time for a little wget magic

  • Joined: 24-August 10
  • Location: localhost
  • OS: Debian Linux, Kernel 3.2.6

Posted 22 March 2013 - 10:05

You cannot upgrade php that apple ships with 10.8 or at least incredibly difficult, i recommend you take a look at homebrew and use the php forumlas from here

#8 OP goodbytes

goodbytes

    Just below average Joe

  • Tech Issues Solved: 1
  • Joined: 07-May 04
  • Location: England

Posted 22 March 2013 - 12:19

I've worked most of it out.

OSX installation of PHP is in /usr/bin/php/ cant be removed, the secondary install is from http://php-osx.liip.ch and is installed in /usr/local/php5/

php -i calls the default version so adding export PATH=/usr/local/php5/bin:${PATH} to the bash profile file overwrites it, i'm now getting a loaded php.ini file and correct information. I can also upgrade to php 5.5 by using the following command curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5

no need for any external software it's all running nicely in the background :)