Home > Backend Development > PHP Tutorial > ubuntu上安装php redis

ubuntu上安装php redis

WBOY
Release: 2016-06-13 13:08:47
Original
1235 people have browsed it

ubuntu下安装php redis

ubuntu下安装php redis

?

1.安装redis服务端

sudo apt-get install redis-server

测试redis是否安装成功:
注意:要开启redis
redis-cli
set myname wangking
OK
get myname
"wangking"

?

2.下载安装redis的php扩展插件,phpredis。
sudo wget http://open.imop.us/pr.tar.gz

tar zxvf pr.tar.gz

cd phpredis

phpize //这个phpize是安装php模块的

如果没有phpize,则需要先安装php5-dev (apt-get install php5-dev)

./configure

make

sudo make install

修改php.ini文件(/etc/php5/apache2/php.ini)
extension=redis.so

重启apache (sudo /etc/init.d/apache2 restart)

?

php test demo:

$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$redis->set('myname','wangking');
echo $redis->get('test');
Copy after login

?

?

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template