Upgrade to PHP 5.4 on MAC and remove version 5.3.10
installation, macos, php
Solution
Update: As of early 2014, you are probably better of installing from http://php-osx.liip.ch/ builds as it contains most extensions. In case you really do need to compile your own, follow the original answer.
Original answer:
Mac comes with a preinstalled php you can easily overwrite.
This is a list of steps I take to update the php I have installed:
Prerequisites:
- Xcode and it's Command line utilities (install form preferences) will give you a gcc compiler to build the php with
- libjpeg, libpng etc. if you want to build with these.
Building and installing php:
- Download the distribution from www.php.net/downloads.php
- Untar the archive and point your console into the location
- Now, having still the original old php installed, run `php -i | head` in the console. What you want is to configure your new php with these flags to ensure you have proper pcre support and everything works just fine.
- In the php source directory you untarred, run the `./configure` script with the flags you just got
- Build php by running `make` and `sudo make install` afterwards. That will actually replace the original php distributed with OS X.
And dont forget to run `make test`...
Ex.: my workflow for building php
wget http://url_to/php_source.tar.gz
tar -zxvf php_source.tar.gz
cd php_source/
php -i | head
./configure --prefix=/usr --with-snmp # ... same flags as previous build
make
sudo make install
Problem
I would tring to update my php version to the version 5.4. When I'm looking via /usr/local/bin/php -v in the console I see the version 5.4.3 and with php -v it tell me there is the version 5.3.10 installed. How can I remove the older version?