linux php安装zookeeper扩展
linux php安装zookeeper扩展
tags:php zookeeper linux ext
前言:
zookeeper提供很犀利的命名服务,并且集群操作具有原子性,所以在我的多个项目中被采用。
在原项目总,服务器集群的状态统一上报到zookeeper集群中,然后通过客户端来访问zookeeper,实时观察集群的状态(当然了,你要做成配置同步也可以)。但是客户端跨平台不方便,开发一个手机客户端又太egg pain了,所以打算采用PHP来读取zookeeper中。
以下是安装php的zookeeper扩展的步骤。多次使用,如有问题请反馈。转载请注明出处。
环境:
|
1
2
3
4
5
|
centos : 6.4 zookeeper : 3.4.5 php : 5.5.10 nginx : 1.5php zookeeper扩展 :0.2.2 |
1、如果没有安装nginx,先安装nginx,可参照:http://hi.baidu.com/solohac/item/081e97e54868403f86d9deff
确保先把nginx配置好,再往下
2、如果没有安装php,先安装php(先把nginx的php支持配置好了之后,再去安装zookeeper的扩展)
下载
wget http://hk2.php.net/distributions/php-5.5.10.tar.gz
解压
tar zxvf php-5.5.10.tar.gz
生成、安装
cd php-5.5.10
|
1
|
./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 |
make && make install
配置php
|
1
2
|
cp php.ini-production /usr/local/php5.5.10/etc/php.inicp /usr/local/php5.5.10/etc/php-fpm.conf.default /usr/local/php5.5.10/etc/php-fpm.conf |
启动
|
1
|
/usr/local/php5.5.10/sbin/php-fpm |
查看端口是否监听
netstat -lnt | grep 9000
编辑nginx配置文件
|
1
2
3
4
5
6
7
8
9
10
11
|
location ~ .*\.(php)?${expires -1s;try_files $uri =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;include fastcgi_params;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_pass 127.0.0.1:9000;} |
nginx重新加载配置
nginx -s reload
测试php访问
cd /usr/local/nginx/html/
vim aa.php
写入内容
|
1
2
3
|
<?phpecho "test php";?> |
如果php能正常访问了,继续下面的安装,如果不行,先回头把php的支持弄好。
2、安装zookeeper
下载
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
解压(随便你放在哪个目录,记得就行)
tar zxfv zookeeper-3.4.5.tar.gz
启动zookeeper服务器
|
1
2
3
4
|
cd zookeeper-3.4.5/confcp zoo_sample.cfg zoo.cfgcd ../bin./zkServer.sh start |
这里最好确认一下是否期待成功,./zkServer.sh status
我这里是单台,所以结果为:
|
1
2
3
4
|
[root@localhost bin]# ./zkServer.sh statusJMX enabled by defaultUsing config: /root/zookeeper-3.4.5/bin/../conf/zoo.cfgMode: standalone |
编译zookeeper库,给php用的
|
1
2
3
|
cd ../src/c./configure --prefix=/usr/local/zookeeperlibmake && make install |
3、安装php的zookeeper扩展
下载
wget http://pecl.php.net/get/zookeeper-0.2.2.tgz
解压(解压出来的package.xml不用去管他)
tar zxvf zookeeper-0.2.2.tgz
把他放到/root/php-5.5.10/ext中
mv zookeeper-0.2.2 /root/php-5.5.10/ext/
cd /root/php-5.5.10/ext/
改目录名字
mv zookeeper-0.2.2 zookeeper
回到php-5.5.10目录
cd ..
./buildconf --force
./configure -h|grep zookeeper
查看configure是否已经支持了zookeeper
|
1
2
3
|
--enable-zookeeper Enable zookeeper support--disable-zookeeper-session Disable zookeeper session handler support--with-libzookeeper-dir=DIR Set the path to libzookeeper install prefix. |
如果显示如上,说明已经支持了,继续往下
cd ext/zookeeper
生成configure
/usr/local/php5.5.10/bin/phpize
生成makefile
|
1
2
3
4
|
./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库的路径 |
编译安装
make && make install
结果为,这个结果接下来的配置要用到
Installing shared extensions: /usr/local/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/
添加ext路径和文件名
|
1
2
3
4
|
vim /usr/local/php5.5.10/etc/php.iniextension_dir="/usr/local/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/"extension=zookeeper.so |
4、重新编译php
进入Php的源码文件夹,不要进错了。我的源码文件夹是/root/php-5.5.10,安装目录是/usr/local/php5.5.10
cd /root/php-5.5.10
rm -rf autom4te.cache/ configure
./buildconf --force
./configure -h|grep zookeeper
查看configure是否已经支持了zookeeper
如果已经支持了,继续往下
./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 install
到这里,已经安装好支持了,来测试下是否正常
在zookeeper-0.2.2.tgz中(也就是Php的zookeeper扩展),有examples/Zookeeper_Example.php文件,可以用来测试
|
1
2
|
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.php |
看是否能打印出如下结果
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
string(0) ""array(1) { [0]=> string(9) "zookeeper"}NULLstring(3) "abc"array(2) { [0]=> string(7) "test123" [1]=> string(9) "zookeeper"}NULLNULLarray(2) { [0]=> string(3) "001" [1]=> string(3) "002"} |
重启php-fpm
killall php-fpm
/usr/local/php5.5.10/sbin/php-fpm
现在就可以通过浏览器访问支持zookeeper扩展的php了
如果还有别的问题,请检查:
1、iptables
2、selinux
linux php安装zookeeper扩展的更多相关文章
- linux下安装opcache扩展
linux下安装opcache扩展 参考:http://www.php.net/manual/zh/opcache.installation.php 1 2 3 4 5 6 7 wget http ...
- Linux上安装Zookeeper以及一些注意事项
最近打算出一个系列,介绍Dubbo的使用. 分布式应用现在已经越来越广泛,Spring Could也是一个不错的一站式解决方案,不过据我了解国内目前貌似使用阿里Dubbo的公司比较多,一方面这个框架也 ...
- 总结 Linux 下安装 PHP 扩展步骤
总结一下 Linux 下安装 PHP 扩展步骤,这里以安装 PHP 的 redis 扩展为例. 一.拿到扩展包下载地址,下载扩展包 pecl 上搜索 redis wget http://pecl.ph ...
- Linux下安装Zookeeper
Zookeeper是一个协调服务,可以用它来作为配置维护.名字服务.分布式部署: 下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路. 一.Zookeeper下载 [ro ...
- linux 下安装php扩展
linux下安装php扩展 步骤: 1.在扩展解压包目录执行 phpize 2.执行 ./configure --with-php-config=/usr/local/php/bin/php-conf ...
- Linux php安装zip扩展
Linux php安装zip扩展 2018.07.22 22:40 1165浏览 #wget http://pecl.php.net/get/zip-1.12.4.tgz #tar zxfv zi ...
- Linux上安装ZooKeeper并设置开机启动(CentOS7+ZooKeeper3.4.10)
1下载Zookeeper 2安装启动测试 2.1上载压缩文件并解压 2.2新建 zookeeper配置文件 2.3安装JDK 2.4启动zookeeper 2.5查看zookeeper的状态 3将Zo ...
- linux centos7 安装zookeeper
linux 系统下 zookeeper 安装教程 1.下载安装包 1)进入安装目录 cd /home/install/ 2)下载 wget http://mirror.bit.edu.cn/apach ...
- php win/linux/mac 安装redis扩展或者扩展报错 zend_smart_str.h file not found
1 windows 安装reids 扩展 根据phpinfo 查看php信息.在pecl.php.net 下载对应的redis扩展版本,放如扩展目录,在php.ini 配置扩展信息,重启服务 2 li ...
随机推荐
- WebApi简单使用
一.建立一个WebApi项目 WebApi项目的文件和MVC的基本项目内容差不多,都有Models View Controller等,区别在于WebApi的控制器继承的不是Controller类,而是 ...
- iOS 根据字符串来定位地址
- (void)viewDidLoad { [super viewDidLoad]; self.geocoder = [[CLGeocoder alloc]init]; // 设置地图可缩放 self ...
- 转载:SMS软件FESWMS模型使用体会
自学了SMS-FESWMS几个月,从其原理到具体应用都已经比较熟悉.感觉这个软件还是有许多不足,这也是需要进一步提高和改进的地方.下面谈谈自己的一些感受和体会. 首先,对一些比较简单的模型,软件的计算 ...
- IIS URL重写找不到页面 (URLRewriter.dll伪静态)
在网站上点右键 属性 进入主目录菜单 点击配置 找到.html扩展名 编辑 将 检查文件是否存在 的钩去掉! OK
- CentOS 卸载已安装软件
根据软件的安装类型,选择合适的卸载方式: 卸载前确定软件的完整的版本号:#rpm -qa ×××*#rpm -ql xxx-xxx //查找安装目录 执行卸载命令:#rpm -e xxx-xxx # ...
- 如何添加localizable.strings本地化
1.在Supporting Files文件夹右键,NewFile… -> iOS -> Resources -> String Files,命名为Localizable.string ...
- VS2013添加NuGet的方法
1.工具->扩展和更新->联机 2.右上角搜索框搜索NuGet,选择NuGet Package Manager for Visual Studio 2013,安装后重启VS 下面通过添加N ...
- [视频]物联网应用-ARM mbed-来至MultiTech Systems的解决方案
ARM公司面向物联网及可穿戴市场,近期可谓是动作频频,先是发布了专为物联网及可穿戴领域而生的Cortex-M7架构,接着又发布了mbed物联网操作系统.意图在物联网领域构筑一套坚不可摧的生态系统. 这 ...
- 学习web前端开发感想
1.学习一个技术,不是一看见源代码就是copy,而是仔细阅读后,找到自己想要的,并且自己写出来,自己理解了,下次遇到同样的问题,自己才能解决. 2.在电脑上学习的过程中,我总是先建立一个文本文档,这样 ...
- php下使用phpmailer发送邮件
由于默认虚拟空间不支持mail()函数,客户需要留言发送邮件,找到phpmailer发送不成功,调试成功后记录一下. 最新的下载地址在github,https://github.com/Synchro ...