Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 935
PHPFan Avatar asked Aug 30 '14 06:08

PHPFan


People also ask

Is PHP 5.6 still supported?

No. The developers of PHP are no longer supporting PHP 5.6. There will not be any more security updates to PHP 5.6, there will not be any more bug fixes to PHP 5.6. You should not use PHP 5.6 (or any version of PHP 5) in a production environment.

Is PHP 5.2 still supported?

Why is this happening? PHP has not supported version 5.2 since 2011 and there are many unpatched security vulnerabilities.

Is PHP 5.4 still supported?

PHP 5.4 end-of-life date is September 14, 2015.

Is PHP5 compatible with PHP7?

You need to be aware that for the most part, PHP 5. x code can run on PHP 7. In PHP 7, there are some backwards incompatible changes, so applications built with PHP 5.


2 Answers

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.

like image 51
DevilishDB Avatar answered Sep 28 '22 00:09

DevilishDB


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.

like image 33
Déjà vu Avatar answered Sep 27 '22 23:09

Déjà vu