redis安装使用
作者:互联网
-
先安装redis服务端
- 下载地址:http://redis.io/download
-
安装
$ wget http://download.redis.io/releases/redis-2.8.17.tar.gz $ tar xzf redis-2.8.17.tar.gz $ cd redis-2.8.17 $ make -
启动服务端
./redis-server ../redis.conf -
启动客户端
./redis-cli
-
redis拓展安装
- 从github下载phpredis扩展
- git clone https://github.com/phpredis/phpredis
- 将phpredis移动到其他目录,此处移动到etc下
- mv phpredis /etc/phpredis
- 编译安装拓展
- yum install php-dev
- phpize
- ./configure
- Make && make install
- 修改php.ini
- extension=/etc/phpredis/modules/redis.so
- 重启apached或者php-fpm
- ps -aux | grep php-fpm
- kill -USR2 进程pid
- php页面打印phpinfo看redis是否安装成功
- php测试代码
$redis = new redis(); $redis->connect('127.0.0.1',6379); $redis->set("test","Helloworld!"); $result = $redis->get("test"); //检测是否连接成功 echo "Server is running: " . $redis->ping(); echo "\n"; echo $result;
标签:tar,phpredis,redis,2.8,使用,php,安装 来源: https://www.cnblogs.com/godehi/p/13087140.html