Install PHP zookeeper on CentOS Server

Install PHP zookeeper on CentOS

PHP zookeeper is a PHP extension that is used for interacting with Apache ZooKeeper.

The latest version of Apache Zookeeper (in .tgz format) can be downloaded from the below URL :

https://pecl.php.net/get/zookeeper

Before installing check whether the version you are downloading is beta, alpha or stable.

Follow the below steps to install PHP zookeeper extension using pecl.

1. First you must log into your CentOS server as ‘root’ user

2. Check whether gcc and make package is installed on the Linux server.

You might get errors if these packages are not installed. Run the below command if gcc and make is not installed.

# yum install gcc make

3. Download and install libzookeeper and libzookeeper-devel rpm

rpm -Ivh libzookeeper-xxxxxx.el7.x86_64.rpm
rpm -Ivh libzookeeper-devel-xxxxxx.el7.x86_64.rpm

4. Run the command ‘pecl install pecl/zookeeper’ to install zookeeper PHP extension

 

# pecl install pecl/zookeeper
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading zookeeper-0.5.0.tgz ...
Starting to download zookeeper-0.5.0.tgz (26,780 bytes)
.........done: 26,780 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Build process completed successfully
Installing '/usr/lib64/php/modules/zookeeper.so'
install ok: channel://pecl.php.net/zookeeper-0.5.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=zookeeper.so" to php.ini


 

5. Check the php loaded configuration file on your server.

Run the command php --ini to find the PHP configuration file path.

6. Add “extension=zookeeper.so” to PHP configuration file /etc/php.ini

echo “extension=zookeeper.so” >> /etc/php.ini

On my server, the PHP configuration file is in /etc/php.ini. Configuration file path might be different on your server.

7. Run the below command to make sure zookeeper PHP extension is enabled

php -m | grep zookeeper
zookeeper

 


 

How to uninstall PHP zookeeper extension

1. Log into server as root user OR login as user with sudo privileges

2. Run the command ‘pecl uninstall pecl/zookeeper’ to remove zookeeper extension.

 

pecl uninstall pecl/zookeeper
Unable to remove "extension=zookeeper.so" from php.ini
uninstall ok: channel://pecl.php.net/zookeeper-0.5.0


 

3. Remove the line “extension=zookeeper.so” from your PHP configuration file.