Installing Gearman and the Gearman PHP Extension on Debian 6 Squeeze

Here's a run though of installing Gearman and the Gearman PHP Extension on Debian 6 Squeeze. I noticed that several other tutorials had steps that did not work properly with the Gearman client version available in PECL at the time that this article was published. The below instructions were ran several times through and verified on a minty fresh Debian 6.0 Squeeze installations spun up from my Rackspace Cloud hosting account.

Update the package lists:

apt-get update

Install Apache and PHP:

apt-get install apache2
apt-get install php5 libapache2-mod-php5 php5-dev php-pear

Install the Gearman job server and libgearman library:

apt-get install gearman-job-server libgearman-dev

If you tried to next isntall Gearman with the "pecl install gearman" command, you would get an error on my system stating "configure: error: Please install libgearman ERROR: `/tmp/pear/temp/gearman/configure' failed." Instead, you'll want to install the latest BETA version of Pecl Gearman at http://pecl.php.net/package/gearman. At the time of writing it was as below:

pecl install channel://pecl.php.net/gearman-0.8.3

Next, you'll want to enable the Gearman extension in PHP. Run the following command and restart Apache to do so:

 echo "extension=gearman.so" >> /etc/php5/conf.d/gearman.ini
/etc/init.d/apache2 restart
That's it! Gearman is ready to use. Check out the basic tutorial at http://gearman.org/getting_started for how to get started with workers and clients.