murshed ahmmad khan (usamurai) on May 1st, 2013
  • Sharebar

If you have already installed Gearman Job server, now it’s time to install the PHP extension to make it usable from PHP scripts.

Gearman API

Gearman PHP Extension
The Gearman PHP extension wraps the C library installed with the Gearman C Job Server package. This provides a client and worker interface in PHP that looks much like the C interface. The PHP extension also extends the procedural interface to provide a native object oriented interface as well. This allows you to use either programming paradigm with the extension. This document will use the object oriented interface.


The Gearman PHP extension is hosted on PECL like most other extensions. Building PHP extensions assumes the PHP development package is installed (php5-dev on Ubuntu and Debian). The PHP command line interface package should also be installed for development and workers (php5-cli on Ubuntu and Debian). The tarball should be downloaded from PECL, and then to build and install run:

1. Install php-devel dependency via yum

# yum install php-devel

2. Get the latest stable build from Gearman PECL extension page. The current stable release is version 1.1.1

# wget
# tar -xzvf gearman-1.1.1.tgz
# cd gearman-1.1.1

3. Now phpize and complie it:

# phpize
# make
# make install

You will finally see something like this:

Installing shared extensions: /usr/lib64/php/modules/

4. Update PHP.INI file:

The following line will need to be added to all php.ini files, usually located in /etc/php*.


5. Restart Web server

Now restart the web server and you’re good to go:

# /etc/init.d/httpd restart

6. Test Connect:

The module should now be usable by all PHP interfaces. Call the excellent Gearman API functions for PHP now.

To test using the PHP command line interface, create gearman_version.php with the following contents:

This can then be run on the command line:

$ php gearman_version.php

You can also read the getting started guide from this page. Or if you want to install it through unix package manager you can also follow this post

Hope it’ll help someone!

Leave a Reply