[SOLVED] Upgrading from PHP 5.5 to PHP 5.6 on Ubuntu 12.04 LTS

Recently I had to upgrade PHP version on the build server based on Ubuntu 12.04 LTS to PHP 5.6 At that moment there was PHP 5.5 installed on the server. Everything should have been as easy and promising as described, for example, in this post. Yes, it was going well to the moment

sudo apt-get dist-upgrade

Then dpkg claimed unmet dependencies… You know, as usual. I decided – f…k it, I will remove existing php and everything related. Simple removal with

sudo apt-get remove php*

did not work fine and stuck on removing phpmyadmin.

That guysexited with an error code 10 being reported from its post-remove script. After pretty short googling, I found the solution which worked for me.

The similar shit happened with php5-imagick package, so the solution I used was similar to phpmyadmin removal. Afterwards, I checked for presence anything starting with or inlcuding php:

sudo dpkg -l | grep php

Everything was clean. OK, here we go…

sudo apt-get clean && sudo apt-get autoclean
sudo apt-get udpate && sudo apt-get upgrade && sudo apt-get dist-upgrade

…and still the same error in result:

Reading package lists… Done Building dependency tree Reading state information… Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: php5 : Depends: libapache2-mod-php5 (>= 5.6.16+dfsg-2+deb.sury.org~precise+1~) but it is not going to be installed or libapache2-mod-php5filter (>= 5.6.16+dfsg-2+deb.sury.org~precise+1~) but it is not going to be installed or php5-cgi (>= 5.6.16+dfsg-2+deb.sury.org~precise+1~) but it is not going to be installed or php5-fpm (>= 5.6.16+dfsg-2+deb.sury.org~precise+1~) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

I tried install with -f flag, package-by-package. Nothing worked. The final unmet dependency was:

sudo apt-get -f install php5-json
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
 
The following packages have unmet dependencies:
 php5-json : Depends: phpapi-20121212
E: Unable to correct problems, you have held broken packages.

And here I stuck, as googling at this point didn’t help me at all… I visited the home of php5.6 PPA hoping to find something there. And a brilliant idea came to my mind – I should check APT’s sources list! I saw this files inside /etc/apt/sources.list.d:

/etc/apt/sources.list.d$ ll
total 32
drwxr-xr-x 2 root root 4096 Jan  5 11:12 ./
drwxr-xr-x 6 root root 4096 Jan  5 11:11 ../
-rw-r--r-- 1 root root  138 Jan  5 10:32 chris-lea-node_js-precise.list
-rw-r--r-- 1 root root  138 Jan  5 10:32 chris-lea-node_js-precise.list.save
-rw-r--r-- 1 root root   60 Jan  5 10:32 nginx-stable-lucid.list
-rw-r--r-- 1 root root   60 Jan  5 10:32 nginx-stable-lucid.list.save
-rw-r--r-- 1 root root  134 Jan  5 10:32 ondrej-php5-5_6-precise.list
-rw-r--r-- 1 root root  134 Jan  5 10:32 ondrej-php5-5_6-precise.list.save
-rw-r--r-- 1 root root  126 Jan  5 10:32 ondrej-php5-precise.list
-rw-r--r-- 1 root root  126 Jan  5 10:32 ondrej-php5-precise.list.save

I realised, the problem could be that packages were overwritten from older php-5.5, which apparently was installed manually to the server some time earlier. Once I removed these two files:

ondrej-php5-precise.list ondrej-php5-precise.list.save

and updated apt one more time, I was able to install PHP 5.6 as usual:

sudo apt-get install php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  shtool libc-client2007e node-node-uuid libicu52 libicu48 libv8-3.7.12.22 libmcrypt4 libt1-5 mlock libssl-dev libvpx1 libssl-doc zlib1g-dev libgd3 libev4 libv8-dev libc-ares2 libev-dev
  libc-ares-dev
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libapache2-mod-php5 php5-cli php5-json php5-readline
Suggested packages:
  php-pear
The following NEW packages will be installed:
  libapache2-mod-php5 php5 php5-cli php5-json php5-readline
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,575 kB of archives.
After this operation, 18.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y

The main idea of this story, before adding new custom repository for PHP, make sure you removed any other old ones! Good luck and happy coding!

Install PHP 5.4 from DotDeb

In case if you want have latest php-5.4 both in CLI and with Apache-2.x it is better to install it through apt-get
You need to add these source to sources.list file:

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

If you are getting this error

W: GPG error: http://packages.dotdeb.org stable Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY E9C74FEEA2098A6E
W: GPG error: http://nginx.org squeeze Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62

you need follow such steps:

gpg --keyserver keys.gnupg.net --recv-key 89DF5277
gpg -a --export 89DF5277 | sudo apt-key add -
gpg --keyserver keyserver.ubuntu.com --recv-key ABF5BD827BD9BF62
gpg -a --export ABF5BD827BD9BF62 | sudo apt-key add -
sudo apt-get update

How to upgrade project from symfony-2.0 to symfony-2.1

Originally, I created a project on the symfony 2.0 version without the vendors (standard edition). All dependencies were installed by

php bin/vendors install

The project was hosted on the git-repository.

Sidenote: when this post is being written, symfony 2.1 was in beta testing.
However, the main trend has been clear and significant changes in the API was not forthcoming.
One of the key innovations in symfony 2.1 – use Composer .
On the Symfony framework website one can find a description of the process of creating a new bare project, but there is no information about how to upgrade an existing one.

Let’s begin, sir.
Initially I tried to just copy the contents of the file composer.json, located in the root directory of the Symnofy framework hosted on github, and run

php composer.phar update

but there are no all the dependencies required for the normal functioning of the project.
That is why I just decided to create a new “empty” project:

php composer.phar create-project symfony/framework-standard-edition path/

in a separate branch of my git-repository and then merge in changes from the original branch with the version of symfony-2.0.

I confess that I had to resolve conflicts in the files apps/AppKernel.php, files config.yml, security.yml and others.
But it was not too difficult task.
Also, it is necessary to upgrade all of the additional bundles you may use to the appropriate version for symfony-2.1
For example, for FOSUserBundle (https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md # installation)
add this to you composer.json

{
    "require": {
        "friendsofsymfony/user-bundle": "*"
    }
}

and then execute the command

php composer.phar update

Also you need to make changes according to the instruction in the forms files, and other places. But all depends on your situation – what features are being used in your project.

So after all the steps above, the project has started successfully.
One of the first visible changes is added some beauty to the web-debug-toolbar – there appeared tooltips with summary information for each of the sections of toolbar. Those tooltips appear when you hover the mouse on the appropriate icon.

PS: A few days ago I found another method of how to upgrade to symfony-2.1: http://buildthedamnproduct.com/upgrading-symfony-to-21-10415