How to Install Gearman on Ubuntu 12.04

Install Gearman Ubuntu 12 04

Gearman is a fantastic, open-source parallel task runner and/or job server. It is simple to implement and works across many different languages. In fact, you can call workers that run in one language from clients in another language. When scaling and parallelization become things you want to tackle, this can be a very useful feature.

Our goal behind this post isn’t to describe Gearman or tell you how great it is; it’s to cover the installation process on Ubuntu 12.04, because it can be confusing, and the Gearman page doesn’t do a great job of describing the process.

The installation is really simple though — you’ll see.

Step 1: Install Python-Software-Properties & the Gearman PPA

In case you don’t have python-software-properties installed, we will need to install it. There is also a Gearman PPA for Ubuntu, so we will add that to our repository list and do an update.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:gearman-developers/ppa
sudo apt-get update

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

Now that we have the respository installed, let’s go ahead and install the Job Server and Tools.

This is pretty straightforward.

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

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

Using PECL, we can simply install the other needed parts of Gearman now.

sudo pecl install gearman

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

Now we need to tell PHP to use the gearman.so extension. If you aren’t sure whether you will be using a web-server-based Gearman or the CLI version, you can install both to be safe. It is important to note that PHP has two separate php.ini files for CLI and Server.

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

Open your php.ini in your favorite text editor.

sudo vim /etc/php5/cli/php.ini

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

extension=gearman.so

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

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

sudo vim /etc/php5/apache2/php.ini

Add the “Dynamic Extension” again in this file.

extension=gearman.so

Restart Apache:

sudo service apache2 restart

Step 5: Try the Examples

Now, you can try the examples found here to verify that you are all set up on Gearman.

Conclusion

Well done! After a simple and straightforward installation, you now have a fantastic task runner.

Have fun with it!

Advertiser Disclosure

HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.

Our Editorial Review Policy

Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.