Installing Gearman Module for PHP7 on Ubuntu

1
12841

If you use Gearman in your PHP projects for parallel processing, and just upgraded your PHP version to PHP7 you will quickly realize that none of your workers are well working anymore.

Or if you are setting up a new Ubuntu server with PHP7 you will soon realize that there is currently no upgraded package to quickly get gearman setup.

Well fear not, in this quick guide I will show you how to make the required updates so you can get up and running real quick.

In order to make sure we have a seamless installation with a fresh server I will list the common commands, but you can start at a different point if you think you already have certain components installed.

All commands should be run as root user or with sudo.

1. Install and update the Gearman PPA

Lets install the software-properties-common package and add the gearmandevelopers ppa to our repository and make sure it is updated.

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

2. Install Gearman Job Server and some other required components and tools

We will be installing the gearmanjobserver and libgearmandev so that we can have the actual gearman server installed aswell as the libraries to compile the PHP module. For this we install PHP7 dev libary aswell as a few tools we will need. Once these are installed lets go ahead and do an upgrade.

sudo apt-get install gearman-job-server libgearman-dev php7.0-dev php-pear wget unzip re2c
sudo apt-get upgrade

3. Download, compile the gearman pecl module and add to php.ini

cd /tmp/
sudo wget https://github.com/wcgallego/pecl-gearman/archive/master.zip
unzip master.zip
cd pecl-gearman-master
sudo phpize
./configure
sudo make
sudo make install
echo "extension=gearman.so" | sudo tee /etc/php/7.0/mods-available/gearman.ini
sudo phpenmod -v ALL -s ALL gearman

4. Restart webserver or PHP FPM

sudo service php7.0-fpm restart
sudo service apache2 restart

If you are running a different version of PHP make sure you make the appropriate changes to the commands or directories mentioned above. ie “/etc/php/7.0/” to “/etc/php/7.1/” etc.

1 COMMENT

  1. Sadly I got stuck on this line:
    It makes me think if I should even try to use gearman. It’s so out of date it seems.

    sudo add-apt-repository ppa:gearman-developers/ppa
    The repository ‘http://ppa.launchpad.net/gearman-developers/ppa/ubuntu bionic Release’ does not have a Release file.
    N: Updating from such a repository can’t be done securely, and is therefore disabled by default.

LEAVE A REPLY

Please enter your comment!
Please enter your name here