Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Install Zookeeper PHP Extension

The following tutorial will install the Zookeeper extension for PHP and has been tested on Ubuntu 14.04 and Debian 8.

Steps

Firstly, we need to manually install Zookeeper. You can go here to grab the latest version/link, which at the time of writing this tutorial is 3.4.8. This will result in us having the headers which prevented us from being able to use other solutions to install the extension.

sudo apt-get install php5-dev -y
wget ftp://ftp.mirrorservice.org/sites/ftp.apache.org/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
tar --extract --gzip --file zookeep*
cd zookeeper-*
cd src/c
./configure --prefix=/usr/
make
sudo make install

Now that we have zookeeper installed, we can compile the php extension.

cd $HOME
sudo apt-get install git -y
git clone https://github.com/andreiz/php-zookeeper.git
cd php-zookeeper
phpize
./configure
make
sudo make install

We've compiled the PHP extension, now we just need to add it to PHP by executing the following command:

sudo echo "extension=zookeeper.so" | \
sudo tee -a /etc/php5/cli/conf.d/20-zookeeper.ini

That's it! Run the following command to check that everything installed correctly:

php -m | grep zookeeper

You should see the following output:

zookeeper

References

Last updated: 16th September 2021
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch