Ditch Ubuntu’s PHP Packages

I had been frustrated with the state of Edgy’s php packages. I have been developing on 5.2.0 since attending the 2006 Zend Conference. I could have built everything myself, but I have been looking for an easy way to maintain the server. I can always move to a custom compiled server if it becomes necessary. Also, I haven’t seen backports for Feisty yet.

My solution has been Dotdeb. Not only do I get updated php binaries but they include the Suhosin Patch.

The installation is very easy:

Edit /etc/apt/sources.list to include
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

then just run
# apt-get update
# apt-get upgrade

you will have to consent to unsigned packages. You should now have updated PHP packages.

PDO segfaults

After getting PDO sucessfully installed on Ubuntu, I discovered that it would segfault on otherwise normal queries. I also fount out that I am not alone. Stuart Herbert has documented the PDO segfaults. This was sort of disappointing, but at least it was assigned in PECL’s bug tracking system.

Getting PDO to work with Ubuntu’s 6.06 LTS (Dapper Drake)

I had recently purchased a small computer to act as my development server but I also wanted it to act as second desktop machines. I have plenty of experience using Debian as a server, but I decided to try the new distribution from Ubuntu.

The install was pretty easy including getting PHP 5.1.2, Apache 2, and MySQL 5 installed using the familiar apt-get command. (I wish they had included php 5.1.4, but this wasn’t a deal breaker)

I was dismayed to find that they didn’t have a package for PDO extension (PHP Database Objects). So I installed the PDO via the pecl command:

bhiv@devserver:~# pecl install pdo

It downloaded, phpized, configured, compiled and installed just fine. The only thing I had to do was add the line:

extension=pdo.so

to the files:

/etc/php/apache2/php.ini
/etc/php/cli/php.ini

(and restart apache)

But what good was the PDO without a driver for a database, in my case MySQL. So I tried:

bhiv@devserver:~# pecl install pdo_mysql

It downloaded, phpized, then failed on the configure command with the error:

configure: error:
You’ve configured extension pdo_mysql, which depends on extension pdo,
but you’ve either not enabled pdo, or have disabled it.

After trying a number of ways to force it to install, trying to foce the dotdeb distribution to install I found the simplest solution was to manually download the package with the following commands:

bhiv@devserver:~# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

bhiv@devserver:~# tar zxvf PDO_MYSQL-1.0.2.tgz

bhiv@devserver:~# cd PDO_MYSQL-1.0.2

bhiv@devserver:~# phpize

bhiv@devserver:~# vi configure
comment out lines 4163-4173

bhiv@devserver:~# ./configure

bhiv@devserver:~# make

bhiv@devserver:~# sudo make install
add the lines:
extension=pdo.so
extension=pdo_mysql.so
to the very bottom of the file.

bhiv@devserver:~# sudo vi /etc/php/apache2/php.ini

bhiv@devserver:~# sudo vi /etc/php/cli/php.ini

bhiv@devserver:~# sudo apache2ctl restart

Hopefully there will be a php-pdo package soon. But until then, this was the simplest way to get PDO installed on your new Ubuntu system.