How to Install Gearman on Ubuntu 14.04

Similar to our guide on installing Gearman on Ubuntu 12.04, this guide will get you all set up and running with Gearman on Ubuntu 14.04.

In case you don’t know, Gearman is a task runner and a job server that allows you to parallelize tasks easily and run different workers in different languages smoothly.

Below we will describe and lay out the necessary steps to getting Gearman installed.

Step 1: Install Software-Properties-Common and the Gearman PPA

In Ubuntu 14.04, python-software-properties were replaced by software-properties-common. We will go ahead and install this along with a useful Gearman PPA.

 Step 2: Install the Gearman Job Server & Dev Tools, & Perform Upgrade

Next, we install the job server and the tools for Gearman. Once again, the beauty of the apt-get command makes this painless and easy.

 Step 3: Install PECL & Use It to Install Gearman (CLI, Client, Worker)

Now, in case you don’t have it, we need to install PECL and then use it to install Gearman.

 Step 4: Update Our php.ini (CLI and Server) to Use Gearman

The last step is to let PHP know to use the gearman.so extension when it runs. There are two php.ini files that generally need to be updated. The first is the CLI version and the other is the Apache version.

For the CLI php.ini (/etc/php5/cli/php.ini)

Open your php.ini in your favorite text editor.

Add the following line in the “Dynamic Extensions” section of your php.ini.

For the Apache-based php.ini (/etc/php5/apache2/php.ini)

Open your php.ini in your favorite text editor. Please note this is a different file than the one we just covered.

Add the “Dynamic Extension” again in this file.

Restart Apache:

Step 5: Try the Examples

Gearman also offers examples you can use to test and verify your Gearman installation.

Conclusion

That was easy, huh?! If you have any problems or any additions, subtractions, or modifications, please let us know in the comments below.

Ryan Frankel

Questions or Comments? Ask Ryan!

Ask a question and Ryan will respond to you. We strive to provide the best advice on the net and we are here to help you in any way we can.

  • Tarun Nagpal

    Thank you very much. It was simple and easy to install gearman.

    • frankel0

      No problem! I’m glad everything worked well for you.

      • Tarun Nagpal

        One more thing i would happy if you help me. Actually i want to create a PHP App using Gearman. Below is the requirement.

        1. I have a database with 1,00,000 records.
        2. I want to create a Job Queue that pick n number of records from it and send the email to them.
        3. After the mail code executed the result IS_SEND should be updated in the same table.
        4. Repeat the steps 2 and 3 Till last record.
        5. The process should be in background only

        Is it possible in Gearman ?

        • frankel0

          Tarun,

          I think this is absolutely possible with Gearman. The trickiest part will be to make sure that you don’t send an email to the same row twice. That part might take a little work (depending on your DB) but Gearman would be well suited to making workers that read the table, send an email, and mark the data as successfully sent.

          • Tarun Nagpal

            Thank you for the guidance. I am trying it and will take your help if needed. I hope this is fine . 🙂

  • Mrudulkumar Shah

    Hello

    Everything worked well except.

    When I fire the below command :

    sudo pecl install gearman

    it gives me error like below:

    downloading gearman-1.1.2.tgz …
    Starting to download gearman-1.1.2.tgz (30,961 bytes)
    ………done: 30,961 bytes
    could not extract the package.xml file from “/build/php5-0LI9sl/php5-5.5.9+dfsg/pear-build-download/gearman-1.1.2.tgz”
    Download of “pecl/gearman” succeeded, but it is not a valid package archive
    Error: cannot download “pecl/gearman”
    Download failed
    install failed

    Any idea for this ?

    Thanks in advance…