Upgrading PHP 5.3 to 5.4 in VPS account

As with most web hosts, the apache, php & mysql versions are woefully stuck in older versions. While PHP 5.3 itself doesn't sound like too old, it's not enough for many latest php packages. Serveral new features were added in PHP 5.4 and the popular PHP packages are keen to take advantage of it. As PHP 5.5 with even more features is now getting stable, PHP 5.4 doesn't sound like too latest.

Why not upgrade to PHP 5.5 then?

But installing PHP 5.5 in better done with Apache 2.4. That is a bigger obstacle as Apache 2.4 have completely different structure and codes. Almost all standard linux web servers use Apache 2.2. It will break web server control panels & also existing website setups. For now, it's better to wait for Webhosts to provide servers running CentOS7 or Ubuntu 14.04 LTS. Both will have Apache 2.4 & PHP 5.5 by default.

What php packages will need PHP 5.4?

Among the popular packages has minimum requirement as PHP 5.4. The widely popular Wordpress already 'recommends' PHP 5.4 while keeping PHP 5.3 as minimum requirement. Latest versions of Zend Framework 2, Symphony 2 all have PHP 5.4 as recommended version. Zend Framework 2 (ZF2) has PHP 5.3.23 as minimum version whereas web servers usually have PHP 5.3.6 or PHP 5.3.10 so you need a PHP upgrade anyway.

Why PHP 5.4 is better than 5.3?

This slideshow says it better.

Among other things it also has a built-in webserver! Great for testing & development.

The upgrade sequence:

As said earlier, do not go for PHP 5.5 in current crop of VPS accounts. I actually tried doing it and with control panel & apache settings were broken I had to re-install VPS bas to it's original setting.

For Ubuntu 12.04 LTS based VPS account, I followed the advice from AskUbuntu ( http://askubuntu.com/questions/109404/how-do-i-install-latest-php-in-sup... ) but not using the one for PHP 5.5.

Ran

 sudo apt-get install python-software-properties 

as add-apt-repository was not provided in VPS

 sudo add-apt-repository ppa:ondrej/php5-oldstable 

to install only the latest PHP 5.4

  sudo apt-get update  

get the new repository loaded

Then checked the available version of PHP using this

 apt-cache policy php5 

it will show the version that will be installed when we ran 'install php5' next time. I wanted to check this as ondrej's responsitory are very frequently updated & wanted to ensure it will not auto upgrade Apache.

Finally, the actual install

 sudo apt-get install php5 

PHP install is over. Not major issue, but it showed a notice that it cannot load 'ioncube-loader' as it was 5.3. Found that Ubuntu 12.04 loads this 'ioncube_loader_lin_5.3.so' from '/usr/lib/php5/20090626+lfs/' folder. Luckily that folder also has another .so file for 5.4. But php still tries to load 5.3 version & fails.

Found that it was due to 00-ioncube-loader-5.3.ini file at '/etc/php5/conf.d' folder. Opened it, there was only one line (apart from comments) that said zend_extension=/usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so
Changed it to zend_extension=/usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.4.so

And it's time to restart apache

 sudo service apache2 restart 

Restarted without a hitch.

Checked PHP version

 php -v 

it shows 5.4.23 (latest version of 5.4 at this time, ondrej adds latest version within days of it being released). And also showed that it loaded ioncub_loader 5.4 now.

Time for now to install website!