# Solved: Upgrading PHP 5.3 to 5.4 on Mac OS X 10.6



## andynic (May 25, 2007)

Hi

I have a development server on a 5 year old Mac that is still running OS X 10.6. Due to resource limitations, I am reluctant to upgrade to a later version of the OS. 

The volunteer organization for whom I do volunteer programming, their web service provider is going to upgrade from PHP v5.2 to 5.4. I've checked the php.net website and there may be some compatibility issues for the website's software. The service provider cannot provide a test environment.

So I would like to upgrade PHP on my Mac from 5.3.6 to 5.4.

My main concern is: Will 5.4 run on my current Mac that is using OS X 10.6.8? or must I also upgrade to a later version of Mac's OS?
tvDev$ php -v
PHP 5.3.26 (cli) (built: Jul 7 2013 18:30:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.1.1, Copyright (c) 2002-2011, by Derick Rethans

I am using MySql version:
tvDev$ mysql -v
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 567
Server version: 5.1.39 MySQL Community Server (GPL)


If upgrading is possible without doing an OS upgrade, will PHP 5.4 require more resources (other than disk space)?
Will I also have to upgrade MySQL?

Thanks for your help.
Andynic


----------



## Headrush (Feb 9, 2005)

I don't run use this software myself, but I did find some info at this site: http://php-osx.liip.ch

PHP 5.6 should run fine on OS X 10.6.

If you install the PHP 5.6 package from the site I added, it will install in /usr/local/ instead of over writing the standard OS X version of PHP. You then just export your PATH variable to include /usr/local/php/ first to use this updated version.

This should be safer and avoids possible issues later.

Hope that helps.

P.S. I would be highly surprised if PHP 5.6 used more resources.


----------



## dvk01 (Dec 14, 2002)

any version of php will run on your mac with no problems

I wouldn't upgrade to any higher version of PHP than 5.4.x if you are using old software on the web server ( website) 
5.5 & 5.6 have quite big changes and might have compatibility issues with some older websites & MySQL

just about anything that currently runs on 5.2 will work on 5.4 

you really have 2 separate queries here 
1. running a newer php on an older mac os 
2. compatibility issues with older software currently running older php
for the compatibility issues ask in web design and development forum. 

I upgraded recently all my websites to use 5.4 from 5.0 then to 5.2 then 5.3 and have had no problems whatsoever 
I am sticking with 5.4 until that reaches EOL because of probably issues with an older smf forum that will have problems with 5.5 & 5.6 

Eventually I will upgrade that to the newer software then I can upgrade the entire server to 5.6


----------



## andynic (May 25, 2007)

Hi Headrush and Derek,

Thanks for your replies.

I like the idea of installing 5.4 next to 5.3 and changing the path. That way, I can easily go back if needed.

In a week or two I will take the plunge and let you know the results, and, I hope, marking the topic "solved".

Andynic


----------



## andynic (May 25, 2007)

Hi,

I have done the upgrade from PHP 5.3 to PHP 5.4. It was not 100% straightforward though.

To install, which was very easy, I used the website suggested above by Headrush, namely http://php-osx.liip.ch/
Using a terminal window, I used the following command from that site: 
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4
PHP 5.4 installed flawlessly in /usr/local leaving PHP 5.3 in tact.

I then restarted Apache with the terminal widow command: sudo apachectl restart

Without any further modifications the following php script displayed 5.4 when called from a browser:
<?php
echo "vsn = " . phpversion() . "
";
?>

When I started the website software however there were a number of incompatibilities in my code. The lion's share were "solved" from an end-user's point of view by adding the following .htaccess file commands:
php_value date.timezone "Europe/Amsterdam" 
php_flag display_errors off
(obviously Europe/Amsterdam needs to be the timezone of where your web server is located.)
This "band-aid" at least gives me the time to leisurely re-code all of the actual incompatibilities.

One incompatibility had to be re-coded immediately, namely mistakenly using &$ in function calls for call-by-reference parameters. More precisely, in some places in my code I had constructs like this:
f(&$actualParam); 
where f was defined as 
function f(&$formalParam) { ... }

Such function calls had to be changed to: f($actualParam);
(The function definitions themselves were ok.)

Another problem was that mysql PDO functions could not be found. To fix that, I had to modify the delivered 5.4 php.ini file:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
; pdo_mysql.default_socket=
; 25 Jul 2015: The preceding line was uncommented and is replaced by the next line
pdo_mysql.default_socket=/private/tmp/mysql.sock

Finally, I had to modify the terminal window PATH so that, for example, the command "php -v"
would return 5.4. (Left unchanged, the result was still 5.3)

Hope this is helpful to anyone else doing this migration.
Andynic


----------



## Headrush (Feb 9, 2005)

andynic, great job explaining everything you did. Although we might not see more posts, this could really help someone searching in the future. Too many people just get an answer, or fix the problem and don't post back to help others.

One question: you said apache automatically used the php 5.4 in the /usr/local directory. Do you know if that is the normal pattern or by chance is /us/local/ listed first in your PATH var already?


----------



## andynic (May 25, 2007)

Hi Headrush,

I'm somewhat inexperienced at this level of OS detail.

After installing PHP 5.4 as described above, without doing anything further, I was pleasantly surprised to see that my test script
<?php
echo "vsn = " . phpversion() . "
";
?>
was showing 5.4

So I assumed that the install shell (see curl command above) must have prefixed the path for me.
I did not do it.

PHP 5.3 on my system is located in /usr/bin
and
PHP 5.4 is in /usr/local/php5-5.4.43-20150710-232236/bin

I'm not even sure where Mac OS X 10.6.8 (Snow Leopard) gets its path info at startup. I assume that is not the same as $PATH when one starts a terminal window.

Andynic


----------

