Install PHP zookeeper On CentOS from source

Install PHP zookeeper On CentOS from source

.

PHP zookeeper extension is used for communicating with Apache Zookeeper service. This PHP extension require Zookeeper C binding.

The latest version of PHP zookeeper (stable, alpha and beta) can be downloaded from the below URL.

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

Before installing PHP zookeeper you must install libzookeeper-devel and libzookeeper on your Linux server. You can download and install the rpm of these packages by searching in google.

Do the below steps to PHP Zookeeper extension from source.

1. First go to /usr/local/src directory

 

[root@server /]# cd /usr/local/src/
[root@server src]#


 

2. Download the latest stable version of Zookeeper extension from php.net website. Download file is in tgz format and you can download it using wget command. Install wget command if it is not installed.

0.5.0 is the latest stable release (release date : 2018-05-14, File size: 26.2kB)

 

[root@server src]# wget https://pecl.php.net/get/zookeeper-0.5.0.tgz

--2019-01-07 16:24:01-- https://pecl.php.net/get/zookeeper-0.5.0.tgz
Resolving pecl.php.net (pecl.php.net)... 104.236.228.160
Connecting to pecl.php.net (pecl.php.net)|104.236.228.160|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26780 (26K) [application/octet-stream]
Saving to: 'zookeeper-0.5.0.tgz.1'

100%[===============================>] 26,780 --.-K/s in 0.01s

2019-01-07 16:24:01 (1.74 MB/s) - 'zookeeper-0.5.0.tgz' saved [26780/26780]

 
3. Untar zookeeper-0.5.0.tgz file after download is completed

Run the command ‘tar xvzf zookeeper-0.5.0.tgz’ to extract

 

# tar xvzf zookeeper-0.5.0.tgz

zookeeper-0.5.0/examples/Zookeeper_Example.php
zookeeper-0.5.0/examples/watch.php
zookeeper-0.5.0/README.markdown
zookeeper-0.5.0/CREDITS
zookeeper-0.5.0/LICENSE
zookeeper-0.5.0/ChangeLog
zookeeper-0.5.0/zookeeper-api.php
zookeeper-0.5.0/config.m4
zookeeper-0.5.0/php_zookeeper.c
zookeeper-0.5.0/php_zookeeper.h
zookeeper-0.5.0/php_zookeeper_private.h
zookeeper-0.5.0/php_zookeeper_session.c
zookeeper-0.5.0/php_zookeeper_session.h
zookeeper-0.5.0/zoo_lock.c
zookeeper-0.5.0/zoo_lock.h
zookeeper-0.5.0/php5to7.h
zookeeper-0.5.0/php_zookeeper_exceptions.c
zookeeper-0.5.0/php_zookeeper_exceptions.h
zookeeper-0.5.0/zookeeper34to35.h


 

4. Change to zookeeper directory using cd command and run phpize

 

[root@server src]# cd zookeeper-0.5.0
[root@server zookeeper-0.5.0]#

[root@server zookeeper-0.5.0]# phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525


 

5. Run configure with --with-libzookeeper-dir to show the location of zookeeper C binding directory.

Run configure with --with-libzookeeper-dir=[Zookeeper-C-Binding-directory]

If you see the below error, then search for exact location of zookeeper.h on your server.

 

checking for libzookeeper...
configure: error: Can't find zookeeper headers

# locate zookeeper.h
/usr/include/zookeeper/zookeeper.h


 

./configure --with-php-config=/usr/bin/php-config --with-libzookeeper-dir=/usr/


 

6. Run ‘make’

 

[root@server zookeeper-0.5.0]# make


 

7. Run ‘make install’

 

[root@server zookeeper-0.5.0]# make install
Installing shared extensions: /usr/lib64/php/modules/


 

8. Add ‘extension=zookeeper.so’ to php.ini

Run the command ‘php -i | grep php.ini’ OR ‘php --ini’ to find the location of your loaded PHP configuration file.

On my centOS server, the php configuration file is in path /etc/php.ini. Open the php.ini file using vi editor and add ‘extension=zookeeper.so’ to the end. Save the file and exit.

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

 

[root@server zookeeper-0.5.0]# php -m | grep -i zookeeper
zookeeper