Installing Gearman for PHP and Ubuntu

I've been using Gearman lately in a project that I'm working on, and of course a month later when I came to deploy the code, I had to look up all over again what was required for a gearman server in order to put it on the new platform. Here is the short version for my future reference (and yours, if you like)


Ubuntu Packages

If you're not on ubuntu then hopefully you can adapt this information for your system, add a comment if you do! For ubuntu I simply needed:

sudo aptitude install gearman-job-server gearman-dev

There should be a running task which is /usr/sbin/gearmand, this listens on port 4730 of localhost by default.

PECL Package

The gearman package in pecl is still in beta (I have no idea why, the documentation seems thin but it does work fine for me), so to install it I had to do:

sudo pecl install gearman-beta

(on Ubuntu 10.10 this worked flawlessly, but there are known issues on earlier versions where make fails due to an old version of libgearman - see the pecl bug for more information)

At this point, everything is set up and I could start using Gearman - I will write more about my experiences as I have them.

12 thoughts on “Installing Gearman for PHP and Ubuntu

  1. Can't wait to hear how it works out for you. I've been thinking of trying gearman myself. It would be great if there was a Windows port. Alas.

  2. One thing to mention is that you may want to utilize the PPA repositories for gearman if utilizing ubuntu. However, they do not have a maverick one at the moment.

    A few things to note about the gearman client in general, if you want to unit test, you will need to create a client for it so that you can wrap the functions since "do" is a keyword :)

    A last mention, is that it is a great idea to wrap it just so that you do not have so many different methods and can utilize constants between:
    do
    doLow
    doHigh

  3. Be sure to checkout the the gearman server's "--job-retries" parameter for poison jobs and a process manager like supervisord to help the PHP workers with their memleaks and fatal errors.

  4. Dean: thanks for the encouragement!

    ficusd: That's a nice link, thanks :) I also referred this really handy post about ZF from CLI, and used that for my workers: http://webfractor.wordpress.com/2008/08/14/using-zend-framework-from-the-command-line/

    Mike: thanks for the pointers! I have ended up not unit testing so far, but I will take your advice when I do.

    Rob: I got the same advice from weierophinney and I am indeed using supervisord. I haven't checked any of the gearman settings though, so thanks for mentioning that!

  5. I've introduced Gearman into a project I'm working on, and since a few people have asked I thought I'd share my experiences. Basically, this application generates some PDFs from a variety of data sources, makes images, and emails it. Since the whole dat

  6. If anyone is trying to install the pecl php extension and getting error like "can't read /usr/lib/libuuid.la: No such file or directory
    libtool: link: `/usr/lib/libuuid.la' is not a valid libtool archive" refer to this: http://mgribov.blogspot.com/2010/05/gearman-pecl-package-on-ubuntu-lucid.html
    Open /usr/lib/libgearman.la as root, and find a line that says:
    dependency_libs=' -L/usr/lib /usr/lib/libuuid.la'

    Replace it with:
    dependency_libs=' -L/usr/lib -luuid'

    if dependency_libs=' -L/usr/lib /usr/lib/libuuid.la' is not found, simply add
    dependency_libs=' -L/usr/lib -luuid' to the end of the file

    Then
    sudo pecl install gearman-beta
    should install the extension

  7. Unfortunately - doesn't seem to be working :(

    Did anyone have a problem like this:

    configure: error: Please install libgearman
    ERROR: `/tmp/pear/temp/gearman/configure' failed

  8. Same error here

    checking whether to enable gearman support... yes, shared
    not found
    configure: error: Please install libgearman

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>