设为首页 加入收藏

TOP

小贝_redis安装与部署
2015-11-21 01:43:17 来源: 作者: 【 】 浏览:0
Tags:小贝 _redis 安装 部署

安装Redis服务及php Redis拓展

一、Redis相关文件下载
二、Redis安装
三、phpredis拓展安装

一、本文档相关文件下载

1、Redis下载地址: http://redis.io/download

2、php Redis拓展下载地址: http://pecl.php.net/package/redis

3、php下载地址: http://php.net/downloads.php

(备注: 本文档下载的是redis为redis-3.0.2.tar.gz而 php redis拓展为redis-2.2.7.tgz)

4、本测试机系统为 CentOS release 6.3 (Final)

php环境为php-5.6.11

二、安装redis服务

1、安装Redis服务

a、tar -zxf redis-3.0.2.tar.gz

b、make && make install

\

2、安装成功后,src会出现如下等可执行文件

\

(备注: mkreleasehdr.sh、redis-check-dump、redis-cli、redis-benchmark、redis-check-aof、redis-sentinel、redis-server、redis-trib.rb

其中: redis-server则是启动redis服务的服务端

redis-cli则是链接redis的客户端

)

3、启动服务及测试redis

3.1、建立目录bin和etc (bin存放redis可以执行文件、etc则存放redis配置文件)

[root@hadoop src]# mv mkreleasehdr.shredis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinelredis-server redis-trib.rb ../bin/

[root@hadoop redisd]# mv redis.conf etc/

3.2、启动redis

[root@hadoop redisd]# ./bin/redis-server./etc/redis.conf

\

3.3、检查redis是否启动 (redis默认端口为6379)

\

3.4、使用内置客户端操作redis

\

3.5、设置redis自启动

修改/etc/rc.local文件

/usr/local/redisd/bin/redis-server /usr/local/redisd/etc/redis.conf>/dev/null &

\

3.6、关闭redis

[root@hadoop redisd]# ./bin/redis-clishutdown

4、常见异常及处理

异常一:make[2]: cc: Command not found

异常原因:没有安装gcc

解决方案:yum installgcc-c++

异常二:zmalloc.h:51:31: error: jemalloc/jemalloc.h: Nosuch file or directory

异常原因:一些编译依赖或原来编译遗留出现的问题

解决方案:make distclean。清理一下,然后再make。

异常三:在make成功以后,需要make test。在make test出现异常。

couldn't execute "tclsh8.5":no such file or directory

异常原因:没有安装tcl

解决方案:yum install -ytcl

三、安装phpredis服务

1、解压压缩包

tar –zxf php redis拓展为redis-2.2.7.tgz

2、进入解压的目录,执行phpize

\

[root@hadoop phpredis]#/usr/local/php/bin/phpize

\

3、安装phpredis拓展

[root@hadoopphpredis]# ./configure --enable-redis --enable-redis-igbinary--with-php-config=/usr/local/php/bin/php-config

[root@hadoopphpredis]# make && make install

\

4、修改php.ini文件,载入对应redis拓展

\

5、重启php,验证是否安装redis拓展

[root@hadoop etc]# pkill -9 php

[root@hadoop etc]# ../sbin/php-fpm

\

6、使用php,测试redis服务

?

echo'xiaobei';

?

$redis= new Redis();

//进行连接

$redis->connect('127.0.0.1',6379);

$redis->set('name','redisis ok');

echo$redis->get('name');

?>

?

\

7、常见异常及处理

异常一: checking for igbinary includes...configure: error: Cannot find igbinary.h

解决方案

下载http://pecl.php.net/get/igbinary-1.1.1.tgz

tar -xzvf igbinary-1.1.1.tgz

cd igbinary-1.1.1

phpize

./configure --with-php-config=/usr/local/php/bin/php-config--enable-igbinary

make

make install

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇小贝_rediskey键值学习 下一篇sql学习笔记(17)----------MySQ..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: