标签:
下载redis
http://www.redis.cn/download.html
下载php的redis扩展
https://github.com/phpredis/phpredis#installation
如redis官网上教程安装redis
下载,解压和安装: $ wget http://download.redis.io/releases/redis-2.8.19.tar.gz $ tar xzf redis-2.8.19.tar.gz $ cd redis-2.8.19 $ make 编译后的可执行文件在src目录中,可以使用下面的命令运行Redis: $ src/redis-server 你可以使用内置的客户端连接Redis: $ src/redis-cli redis> set foo bar OK redis> get foo "bar"
安装phpredis
[root@localhost server]# ls mysql mysql-5.6.21 nginx nginx-1.4.4 php php-5.5.7 phpredis redis-2.8.19 redis-2.8.19.tar.gz [root@localhost server]# cd phpredis/ [root@localhost phpredis]# ls arrays.markdown config.w32 debian library.h package.xml redis_array.c redis_array_impl.h redis_session.h tests common.h COPYING debian.control mkdeb-apache2.sh php_redis.h redis_array.h redis.c rpm config.m4 CREDITS library.c mkdeb.sh README.markdown redis_array_impl.c redis_session.c serialize.list [root@localhost phpredis]# /alidata/server/php/bin/phpize Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212 [root@localhost phpredis]# ./configure --with-php-config=/alidata/server/php/bin/php-config [root@localhost phpredis]# make [root@localhost phpredis]# make install Installing shared extensions: /alidata/server/php/lib/php/extensions/no-debug-non-zts-20121212/ 然后在php.ini里添加extension=redis.so
测试代码
<?php $redis = new Redis(); $redis->connect(‘127.0.0.1‘,6379); $redis->set(‘helloredis‘,‘i am ok‘); echo $redis->get(‘helloredis‘); ?>
标签:
原文地址:http://www.cnblogs.com/webclz/p/4201461.html