Home > php教程 > php手册 > body text

ubuntu下安装php redis

WBOY
Release: 2016-06-12 20:08:29
Original
1309 people have browsed it


ubuntu下安装php redis

sudo apt-get install redis-server

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

下载phpredis
sudo wget http://open.imop.us/pr.tar.gz

tar zxvf pr.tar.gz

cd phpredis

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

如果没有phpize,则需要先安装php5-dev

./configure

make

make install

修改php.ini文件
extension=redis.so

重启apache

 

demo:

<span style="color: #800080;">$redis</span> = <span style="color: #0000ff;">new</span> Redis();<br><span style="color: #800080;">$redis</span>->connect('127.0.0.1',6379);<br><span style="color: #800080;">$redis</span>->set('test','hello world!');<br><span style="color: #0000ff;">echo</span> <span style="color: #800080;">$redis</span>->get('test');
Copy after login



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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!