Installation method: 1. Install and start the zookeeper server; 2. Download the zookeeper extension and extract it to the ext directory of the PHP installation directory; 3. In the PHP installation directory, execute the command to generate configure and makefile; 4 , Use the make command to compile and install.
The operating environment of this tutorial: centos6.4 system, PHP5.5.10 version, DELL G3 computer
ZooKeeper is a distributed, open The source code distributed application coordination service is an open source implementation of Google's Chubby and an important component of Hadoop and Hbase. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name services, distributed synchronization, group services, etc.
The goal of ZooKeeper is to encapsulate complex and error-prone key services and provide users with simple and easy-to-use interfaces and a system with efficient performance and stable functions.
To use zookeeper in php, you must first install the php zookeeper extension. To install the php zookeeper extension, you must first install zookeeper
How to install the php zookeeper extension
Environment:
centos : 6.4
zookeeper : 3.4.5
php : 5.5.10
nginx : 1.5
php zookeeper extension: 0.2.2
If nginx is not installed, install nginx first; make sure to configure nginx first before proceeding
If php is not installed, install php first (first configure nginx’s php support, and then install the zookeeper extension)
Install zookeeper
Download
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
Unzip (whichever directory you put it in, just remember it)
tar zxfv zookeeper-3.4.5.tar.gz
Start the zookeeper server
cd zookeeper-3.4.5/conf cp zoo_sample.cfg zoo.cfg cd ../bin ./zkServer.sh start
The most important thing here To confirm whether you expect success, ./zkServer.sh status
I have a single server here, so the result is:
[root@localhost bin]# ./zkServer.sh status JMX enabled by default Using config: /root/zookeeper-3.4.5/bin/../conf/zoo.cfg Mode: standalone
Compile the zookeeper library for PHP
cd ../src/c ./configure --prefix=/usr/local/zookeeperlib make && make install
Install the zookeeper extension for php
##Download
wget http://pecl.php.net/get/zookeeper-0.2.2.tgz
Unzip(Don’t worry about the unzipped package.xml)
tar zxvf zookeeper-0.2.2.tgz
Put it in /root/php-5.5.10/ext
mv zookeeper-0.2.2 /root/php-5.5.10/ext/ cd /root/php-5.5.10/ext/Change directory Name
mv zookeeper-0.2.2 zookeeper
Go back to the php-5.5.10 directory
cd .. ./buildconf --force ./configure -h|grep zookeeperCheck whether configure already supports zookeeper
--enable-zookeeper Enable zookeeper support --disable-zookeeper-session Disable zookeeper session handler support --with-libzookeeper-dir=DIR Set the path to libzookeeper install prefix.If it is displayed as above, The description is already supported, continue below
cd ext/zookeeper
Generate configure
/usr/local/php5.5.10/bin/phpize
Generate makefile
./configure --with-php-config=/usr/local/php5.5.10/bin/php-config --with-libzookeeper-dir=/usr/local/zookeeperlib 注意上面的路径: --with-php-config是php安装的路径 --with-libzookeeper-dir是第一步中install zookeeper库的路径
Compile and install
make && make installThe result is, the next configuration of this result will be used
Installing shared extensions: /usr/local/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/
Add the ext path and file name
vim /usr/local/php5.5.10/etc/php.ini extension_dir="/usr/local/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/" extension=zookeeper.so
Recompile php
Enter the source code folder of Php, don’t enter it by mistake. My source code folder is /root/php-5.5.10, and the installation directory is /usr/local/php5.5.10cd /root/php-5.5.10 rm -rf autom4te.cache/ configure ./buildconf --force ./configure -h|grep zookeeperCheck if configure already supports zookeeperIf it already supports it , continue down
./configure --prefix=/usr/local/php5.5.10 --with-config-file-path=/usr/local/php5.5.10/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-zookeeper --with-libzookeeper-dir=/usr/local/zookeeperlib --enable-sockets
make && make installHere, the support has been installed, let’s test whether it is normalIn zookeeper-0.2.2.tgz (that is, the zookeeper extension of Php), there is examples/Zookeeper_Example.php file can be used to test
cp /root/php-5.5.10/ext/zookeeper/examples/Zookeeper_Example.php /usr/local/nginx/html/ /usr/local/php5.5.10/bin/php /usr/local/nginx/html/Zookeeper_Example.phpto see if the following results can be printed
string(0) "" array(1) { [0]=> string(9) "zookeeper" } NULL string(3) "abc" array(2) { [0]=> string(7) "test123" [1]=> string(9) "zookeeper" } NULL NULL array(2) { [0]=> string(3) "001" [1]=> string(3) "002" }Restart php-fpm
killall php-fpm /usr/local/php5.5.10/sbin/php-fpmYou can now pass The browser accesses PHP that supports zookeeper extensionIf there are other problems, please check:1, iptables2, selinuxrecommended Study: "
PHP Video Tutorial"
The above is the detailed content of How to install php zookeeper extension. For more information, please follow other related articles on the PHP Chinese website!

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
