首页 > php教程 > php手册 > 正文

Redis — CentOS6.4安装Redis以及安装PHP客户端phpredis

php中文网
发布: 2016-06-06 19:43:25
原创
1463人浏览过

一、安装redis 1.下载安装包 wgethttp://download.redis.io/releases/redis-2.8.6.tar.gz 2.解压包 tarxzfredis-2.8.6.tar.gz 3.编译 cdredis-2.8.6 make 出现 -bash:make:commandnotfind错误 解决方法: rpm -qa | grep make 提示只安装了automake包 yum in

一、安装redis

1.下载安装包

wget http://download.redis.io/releases/redis-2.8.6.tar.gz

2.解压包

tar xzf redis-2.8.6.tar.gz

立即学习PHP免费学习笔记(深入)”;

3.编译

cd redis-2.8.6

make

出现 “-bash:make:command not find”错误

解决方法:

rpm -qa | grep make 

提示只安装了automake包

yum install make

yum install imake

OK!

make   /*再次编译*/

4.编译测试

make test

提示“You need tcl 8.5 or newer in order to run the Redis test”错误

解决方法:

安装tcl

 

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz

cd tcl8.6.1-src

cd unix

./configure --prefix=/usr           \

            --without-tzdata        \

            --mandir=/usr/share/man \

            $([ $(uname -m) = x86_64 ] && echo --enable-64bit) &&

make &&sed -e "s@^\(TCL_SRC_DIR='\).*@\1/usr/include'@" \

    -e "/TCL_B/s@='\(-L\)\?.*unix@='\1/usr/lib@" \

    -i tclConfig.shmake install &&

make install-private-headers &&

ln -v -sf tclsh8.6 /usr/bin/tclsh &&

chmod -v 755 /usr/lib/libtcl8.6.so

再次测试编译

 

cd redis-2.8.6

make test

4.配置redis

vim redis.conf

daemonize yes #使得进程在后台运行

dir /usr/lcoal/redis/db  #磁盘存储redis数据库文件位置

5.启动redis

cd src

./redis-server

提示“Warning: no config file specified,using the default config.In order to specify a config file use ./redis-server /path/to/redis.conf”以及“WARNING overcommit_memory is set to 0!Background save may fail under low memory condition.To fix this issue add 'vm.overcommit_memory=1' to /etc/sysctl.conf....“两个警告

安装提示操作:

①修改sysctl文件,/sbin/sysctl -p,使修改生效

②./redis-server /etc/redis.conf  以这种方式启动redis服务 (我将配置文件移到了/etc目录下)

6.体验redis

> cd src

> ./redis-cli   #启动redis客户端

> ping

PONG

> set foo bar

OK

> get foo

"bar"

> incr mycounter

(integer) 1

> incr mycounter

(integer) 2

7.安装redis

将redis二进制文件安装在/usr/local/bin目录

make install

8.redis安全

进入redis客户端默认无需密码,可通过配置文件修改密码

① vim /etc/redis.conf

加上:requirepass cJHzy2Z2T8csYspcwwsODHApNko9tg

② 重启redis

幸福女淘宝客
幸福女淘宝客

幸福女淘宝客是一款用php来开发的淘宝分享购物网站,它包含文章、产品系统、金币兑换、金币抢拍、团购、店铺管理系统、订单系统等功能。没有最强大 只有更强大 目前功能最强大的淘宝客系统支持qq 微博登陆 支持关键词搜索淘宝商品支持绑定微博账号发布支持手机访问客户端可以从appcan直接生成安装http://localhot/install 想重新安装 请删除 /config/install.lock安

幸福女淘宝客 1
查看详情 幸福女淘宝客

kill 26743redis进程号)

/usr/local/bin/redis-server /etc/redis.conf

③ 使用redis

/usr/local/bin/redis-cli 也可/usr/local/bin/redis-cli -a 密码 进入客户端

> set h2 helloworld

(error) NOAUTH Authentication required.

> auth cJHzy2Z2T8csYspcwwsODHApNko9tg

OK

> get h2

(nil)

> set h3 abc

> get h3

"abc"

也可通过config set命令动态修改密码

> config get requirepass

1) "requirepass"

2) "cJHzy2Z2T8csYspcwwsODHApNko9tg"

> config set requirepass UHLc565HXduJ5730g8tAcsvNxRUQhY

OK

> auth UHLc565HXduJ5730g8tAcsvNxRUQhY

> set h6 kkkkk

OK

> get h6

"kkkkk"

> exit

查看配置文件,还是原密码,表示config未保存至配置文件

requirepass cJHzy2Z2T8csYspcwwsODHApNko9tg

二、安装redisphp客户端

1.安装git

yum install git

git clone https://github.com/nicolasff/phpredis.git

2.用phpize扩展php扩展模块

/usr/bin/phpize

出现”Cannot find config.m4.Make sure that you run '/usr/bin/phpize' in the top level source direcotory of the module“错误

解决方法:

wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
tar -zvxf m4-1.4.9.tar.gz
cd m4-1.4.9/
./configure && make && make install

还是不行,接着

cd phpredis

/usr/bin/phpize   (里面有config.m4所以可以使用phpize)

ok!

3.配置

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

4.编译和安装

make && make install

5.修改php的配置文件

cd/etc/php.d

vim redis.ini

加上extension=redis.so

6.重启apache

service httpd restart

7.测试

phpinfo();查看redis是否正确安装

三、参考资料

redis官网 http://redis.io/

redis命令 http://redis.io/commands

tcl安装 http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html

通过epel 安装redis http://blog.sina.com.cn/s/blog_6364150101019701.html

http://www.codesky.net/article/201110/170019.html

EPEL(Extra Packages for Enterprise Linux) http://fedoraproject.org/wiki/EPEL

 

 

 

 

 

 

 

 

 

 

相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号