php教程 php手册 Redis — CentOS6.4安装Redis以及安装PHP客户端phpredis

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

Jun 06, 2016 pm 07:43 PM
php redis 설치하다 고객

一、安装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

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

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

 

 

 

 

 

 

 

 

 

 

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드 Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드 Dec 24, 2024 pm 04:42 PM

Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드

CakePHP 날짜 및 시간 CakePHP 날짜 및 시간 Sep 10, 2024 pm 05:27 PM

CakePHP 날짜 및 시간

CakePHP 파일 업로드 CakePHP 파일 업로드 Sep 10, 2024 pm 05:27 PM

CakePHP 파일 업로드

CakePHP 라우팅 CakePHP 라우팅 Sep 10, 2024 pm 05:25 PM

CakePHP 라우팅

CakePHP 토론 CakePHP 토론 Sep 10, 2024 pm 05:28 PM

CakePHP 토론

CakePHP 빠른 가이드 CakePHP 빠른 가이드 Sep 10, 2024 pm 05:27 PM

CakePHP 빠른 가이드

CakePHP 프로젝트 구성 CakePHP 프로젝트 구성 Sep 10, 2024 pm 05:25 PM

CakePHP 프로젝트 구성

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법 PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법 Dec 20, 2024 am 11:31 AM

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법

See all articles