ubuntu 16.04 环境中安装 php7.0 redis扩展
2016-09-24 17:49
816 查看
安装配置步骤如下:
1.root@ubuntu:/tmp# git clone -b php7 https://github.com/phpredis/phpredis.git 2.root@ubuntu:/tmp# mv phpredis/ /etc/
3.root@ubuntu:/tmp# cd /etc/phpredis
4.root@ubuntu://etc/phpredis# phpize
5.root@ubuntu://etc/phpredis# ./configure
6. root@ubuntu://etc/phpredis#make && make install
7.root@ubuntu://etc/phpredis#vi /etc/php/7.0/fpm/conf.d/redis.ini 中 写入(extension=/etc/phpredis/modules/redis.so)退出保存
8.root@ubuntu://etc/phpredis#vi /etc/php/7.0/apache2/php.ini 中写入 (extension=/etc/phpredis/modules/redis.so)
9. 重启apache2 /etc/init.d/apache2 restart
./redis-serverredis.conf开启redis后台服务。
如果你修改redis.conf中的任何配置,需要关闭redis-server进程后,再./redis-serverredis.conf重新开启redis后台服务。
在phpinfo 查查看是否成功
代码测试
<?php
//连接本地Redis服务
$redis=new Redis();
$redis->connect('localhost','6379'); //$redis->auth('admin123');//如果设置了密码,添加此行
//查看服务是否运行
$redis->ping();
//选择数据库
$redis->select(5);
//设置数据
$redis->set('school','WuRuan');
//设置多个数据
$redis->mset(array('name'=>'jack','age'=>24,'height'=>'1.78'));
//存储数据到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
//获取存储数据并输出
echo $redis->get('school');
echo '<br/>';
$gets=$redis->mget(array('name','age','height'));
print_r($gets);
$tl=$redis->lrange("tutorial-list", 0 ,5);
print_r($tl);
?>php 操作redis相关文章
PHP操作Redis LIST ,SET, HASH 的相关命令 (一)
PHP操作Redis KEY,String 的相关命令 (二)
PHP操作Redis 有序集(Sorted Set) 的相关命令 (三)
参考文章:http://www.cnblogs.com/GaZeon/p/5422078.html
1.root@ubuntu:/tmp# git clone -b php7 https://github.com/phpredis/phpredis.git 2.root@ubuntu:/tmp# mv phpredis/ /etc/
3.root@ubuntu:/tmp# cd /etc/phpredis
4.root@ubuntu://etc/phpredis# phpize
5.root@ubuntu://etc/phpredis# ./configure
6. root@ubuntu://etc/phpredis#make && make install
7.root@ubuntu://etc/phpredis#vi /etc/php/7.0/fpm/conf.d/redis.ini 中 写入(extension=/etc/phpredis/modules/redis.so)退出保存
8.root@ubuntu://etc/phpredis#vi /etc/php/7.0/apache2/php.ini 中写入 (extension=/etc/phpredis/modules/redis.so)
9. 重启apache2 /etc/init.d/apache2 restart
./redis-serverredis.conf开启redis后台服务。
如果你修改redis.conf中的任何配置,需要关闭redis-server进程后,再./redis-serverredis.conf重新开启redis后台服务。
在phpinfo 查查看是否成功
代码测试
<?php
//连接本地Redis服务
$redis=new Redis();
$redis->connect('localhost','6379'); //$redis->auth('admin123');//如果设置了密码,添加此行
//查看服务是否运行
$redis->ping();
//选择数据库
$redis->select(5);
//设置数据
$redis->set('school','WuRuan');
//设置多个数据
$redis->mset(array('name'=>'jack','age'=>24,'height'=>'1.78'));
//存储数据到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
//获取存储数据并输出
echo $redis->get('school');
echo '<br/>';
$gets=$redis->mget(array('name','age','height'));
print_r($gets);
$tl=$redis->lrange("tutorial-list", 0 ,5);
print_r($tl);
?>php 操作redis相关文章
PHP操作Redis LIST ,SET, HASH 的相关命令 (一)
PHP操作Redis KEY,String 的相关命令 (二)
PHP操作Redis 有序集(Sorted Set) 的相关命令 (三)
参考文章:http://www.cnblogs.com/GaZeon/p/5422078.html
相关文章推荐
- ubuntu 16.04安装php7.0 redis扩展及使用php操作redis
- ubuntu16.04安装PHP7.0的laravel必须扩展
- Ubuntu16.04 安装PHP7.0扩展
- 在homestead php7的ubuntu环境中安装 php redis扩展的方法
- ubuntu安装PHP7.0以及memcache,redis等常用扩展
- Ubuntu php7.0环境 安装memcached和Redis
- Ubuntu16.04 中PHP7.0 安装pdo_mysql 扩展
- Ubuntu16.04 中PHP7.0 安装pdo_mysql 扩展
- Ubuntu16.04安装redis和php的redis扩展
- ubuntu16.04安装PHP7.0的laravel必须扩展
- Ubuntu16.04 中PHP7.0 安装pdo_mysql 扩展
- Ubuntu16.04 中PHP7.0 安装pdo_mysql 扩展
- ubuntu php7.0 默认没有redis扩展,下面是安装方法
- Ubuntu16.04 上 Redis 4.0 及php-redis扩展的安装和使用
- php7.0安装Redis扩展 (windows环境)
- ubuntu 16.04 安装php7.0扩展
- 在windows环境下安装redis和phpredis的扩展
- Ubuntu server 14 安装redis及php redis 扩展
- Ubuntu 16.04 64位中文版 配置 LAMP+phpMyAdmin PHP(7.0)开发环境