PHP擴展libzookeeper(https://github.com/Timandes/libzookeeper)主要用於使用PHP代碼連接Zookeeper集群。
擴展對原Zookeeper C Client(https://zookeeper.apache.org/)的功能進行了簡化,強調簡單性與易用性。
同時,本着開放的精神,允許更多的參與到Zookeeper的開發與使用當中。
libzookeeper擴展依賴於Zookeeper C Client,后者包含在Zookeeper的安裝包中,具體安裝方法參看:https://zookeeper.apache.org/doc/r3.5.0-alpha/zookeeperProgrammers.html#Installation。
下面介紹libzookeeper的安裝步驟(以v0.3.1為例):
1)下載並解壓縮安裝包:
wget https://github.com/Timandes/libzookeeper/archive/v0.3.1.tar.gz libzookeeper-0.3.1.tar.gz
tar xvf libzookeeper-0.3.1.tar.gz
2)編譯並安裝擴展:
cd libzookeeper-0.3.1
phpize
./configure --with-libzookeeper=/path/to/zookeeper_c_client
make
make install
其中,/path/to/zookeeper_c_client代表已安裝好的Zookeeper C Client的路徑。
3)編輯php.ini,插入如下代碼行:
extension=libzookeeper.so
4)如果使用PHP-FPM,則需要重啟該服務:
service php-fpm restart
5)檢查擴展加載情況:
php -m | grep libzookeeper
在安裝過程中出現任何問題,均可以前往https://github.com/Timandes/libzookeeper發問。