Can I migrate from PHP 5.3.10 to PHP 5.6.0?

PHPFan picture PHPFan · Aug 30, 2014 · Viewed 30.7k times · Source

I'm basically a PHP developer. I'm currently using Ubuntu Linux 12.04 LTS on my local machine.

I'm using the following PHP version for developing my PHP project:

php -v //command run at terminal to know the `PHP` version installed

PHP 5.3.10-1ubuntu3.13 with Suhosin-Patch (cli) (built: Jul  7 2014 18:54:55) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Now a couple of days back a new latest stable release of PHP version (PHP 5.6.0) was released by the PHP development team.

My question is, as I'm using a PHP version on my local machine which is too old, and also all PHP versions lower than 5.4 are officially unsupported or announced end-of-life, should I go for PHP 5.6.0?

If your answer is yes, please explain me how to do it? Will the code I written in my project work properly after this migration? What changes I'll need to do?

If your answer is no, please explain me in detail why?

Before asking this question I've gone through Google and PHP documentation. There I found migration notes for following version migrations:

   **5.3.x->5.4.x
   5.4.x->5.5.x
   5.5.x->5.6.x**

Didn't get how to migrate from PHP 5.3.10 to PHP 5.6.0.

So can someone please help me in this regard?

If you need any further information regarding my issue please do let me know.

Answer

DevilishDB picture DevilishDB · Aug 30, 2014

TL;DR PHP 5.3.x will still get security upgrades by Ubuntu but upgrade to 14.04.1 for a newer version

You could download and build/install the source for PHP 5.6 from the website, but don't, since it means you risk losing stability with your system because other packages on your system won't be designed for this version and you'll have to upgrade it manually every time a new version comes out, risking stability if those upgrades are security-related since you won't get them upgraded quickly like you would using a package manager.

Instead, I suggest you upgrade your distribution to Ubuntu 14.04.1, which contains PHP 5.5.9; a lot newer than 5.3.10. Of course, 5.3.x will still receive security updates until Ubuntu 12.04 reaches EOL but if you want the latest features you should dist-upgrade. You can do this graphically in the Ubuntu software updater or run apt-get dist-upgrade as root (e.g with sudo) in the TTY if you're using the server version. Update: use sudo do-release-upgrade instead.

Edit: Just to clarify, apt-get is the package manager. If you usually use graphical tools to install and update packages (ubuntu software center, synaptic, etc.), here are some simple commands. # indicates that it must be ran as root (e.g. sudo apt-get install <package>), $ indicates you don't need sudo. Replace things in with the thing you want to use (e.g. apt-get install chromium-browser)

# apt-get update updates the repositories
# apt-get upgrade upgrades the to the newer packages (run the above first!)
# apt-get upgrade <package> is like above, but only upgrades a single package (not that useful unless you have a specific reason)
# apt-get install <package> installs a package
# apt-get remove <package> removes a package
# apt-get autoremove automatically removes packages that were installed by dependencies and no longer needed
$ apt-cache search <query> searches for the query you gave
$ apt-cache show <package> shows info for a package
# yes "" | apt-get install <package> installs a package answering the default answer to everything (you can use yes with lots of commands)
# apt-get dist-upgrade upgrades everything (and removes some packages) when it might usually be held back.