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

2

12

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.

Nordrheinwestfalen answered 30/8, 2014 at 6:38 Comment(3)
You should always use your package manager for updating software. Update manually only when absolutely necessary, therefore when the package is missing from official repositores, and you don't want to use third party repositores.Cacophony
@Luka:What is mean by package manager and which package manager should I use?Nordrheinwestfalen
A package manager is a program which is used to search and install packages and its dependencies automatically. apt is an example of a package manager. All Debian-based distributions (therefore Ubuntu as well) have it by default. RedHat-based distributions, for instance, have yum. So you should always install updates using apt-get install php. In case the package is already installed and there are new updates available, they will be installed. If the package isn't installed at all, it will be installed a few moments after running apt-get install. Look at DevilishDB's answer.Cacophony
I
8

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.

Illboding answered 30/8, 2014 at 7:0 Comment(1)
I found a redditor. Sick himSpacing
T
5

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.

Thiazine answered 31/8, 2014 at 8:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.