I have tried to postpone the upgrade for PHP 5.3 to PHP 5.4 on ourDebian 6 “Squeeze” for good reason so I do not make more damage to our devteam. All is now tested out and it seems that our server and coders are ready to get the upgrade to PHP 5.4. The steps are simply and easy and all are mentioned here bellow. Sticking with standard (stable) Debian packages is generally a good idea. They provide a comfort of superior security and stability and are tested daily on thousands of production servers worldwide. However mostly time they are outdated and compiling from source can bring another issues – dependencies. The best way to do this is use DotDeb – this is a repository containing packages to turn your Debian boxes into powerful, stable and up-to-date LAMP servers. First lets check the version ofPHP running on my server:
su [email protected]#php --version PHP 5.3.22-1~dotdeb.0 with Suhosin-Patch (cli) (built: Mar 2 2013 23:12:49) Copyright (c) 1997-2013 The PHP Group
As you can see I am running PHP5.3 version currently on my server. Now lets do the steps to update 5.3 to 5.4. You will need edit repo file and add few links to it as show bellow
su [email protected]# gedit /etc/apt/sources.list #Add these lines into the end of the sources.list # Main dotdeb repository deb http://packages.dotdeb.org squeeze all deb-src http://packages.dotdeb.org squeeze all # PHP 5.4 deb http://packages.dotdeb.org squeeze all deb-src http://packages.dotdeb.org squeeze all deb http://packages.dotdeb.org squeeze-php54 all deb-src http://packages.dotdeb.org squeeze-php54 all
Now you will need to import and add GPG key
wget http://www.dotdeb.org/dotdeb.gpg cat dotdeb.gpg | sudo apt-key add -
Now is time to remove the PHP5.3 and get PHP5.4 on your server, however before you do this, it is recommend to save your php.ini file to other location.You can find the location of php.ini by running command find / -name php.ini or use phpinfo() page to locate the file. Now lets remove the old PHP5.3 from your system
su [email protected]#apt-get remove --purge php*
Next step is to install your new PHP5.4 on the server, however note the command line since we are using DotDeb there is additional stuff.
su [email protected]# apt-get install -t squeeze-php54 php5 php5-mysql php5-imagick php5-json
As you can see in the line you have to use “-t squeeze-php54” to use the repository. Once you updated the packaged, you will need top restart the webserver.
su /etc/init.d/apache2 restart
Now you should have the updated PHP5.4 running on your box.