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 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
# wget http://pecl.php.net/get/gearman-1.1.1.tgz
# tar -xzvf gearman-1.1.1.tgz
# cd gearman-1.1.1
3. Now phpize and complie it:
# 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
Hope it’ll help someone!