Can I migrate from PHP 5.3.10 to PHP 5.6.0? [closed] Can I migrate from PHP 5.3.10 to PHP 5.6.0? [closed] php php

Can I migrate from PHP 5.3.10 to PHP 5.6.0? [closed]


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.


Upgrade to Ubuntu 14.04.1 in order to get PHP 5.5.9 as a package, and benefit from Ubuntu upgrades. I wouldn't go for 5.6.0 in a production environment anyway.

From this PHP page you get information about the migrations from 5.3 to 5.4 and 5.4 to 5.5.

Besides the changes and new features mentioned, the PHP teams have worked on memory management and optimization between 5.3 and 5.5.9. These improvements alone motivate the migration.

Pieces of advice for the migration

  • APC: PHP now embeds OPCache as a replacement of APC. If you used APC variables, some information about OPCache is available - in my case using the old APC via the new module (name change), php5-apcu (note the 'u'), was the best alternative.

  • The modules were installed in a different directory. If you intend to keep your php.ini the extension_dir may have to be adjusted

  • In addition, the /etc/php5 dir is more demanding in terms of structure: below that dir is mods-available (à la nginx) that contains the list of modules ini files. Then in cli, fpm, apache2... dirs is a conf.d dir that has symbolic links to that main mods-available modules ini files ; add only a link if you intend to use that module for that PHP configuration (eg mysqli may not be necessary for cli).

  • JSON: the module php5-json has to be installed (apt-get install php5-json) in order to get the PHP JSON functions (json_encode, decode...)

  • note that it seems there is a problem linking /etc/php5/MODE/php.ini (MODE being cli, ...) to a main php.ini somewhere (eg in fpm) - during Ubuntu updates, an error prevents the installation - I just copied the php.ini since they're the same for all modes in my case.

Besides that the migration went smoothly.