配置php redis 扩展
参照runoob:PHP 使用 Redis
Windows:
- 假设redis已经安装好 服务启动
- xampp (php 7.1 x86 windows)
查看phpinfo (php 7.1 x86/x64 ts/uts vc14/vc15)
Zend Extension Build API320160303,TS,VC14
PHP Extension Build API20160303, TS,VC14
https://windows.php.net/downloads/pecl/releases/igbinary/2.0.6rc1/
https://windows.php.net/downloads/pecl/releases/redis/3.1.3/
; php.ini
extension=php_igbinary.dll
extension=php_redis.dll
查看phpinfo 有redis扩展
test
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//设置 redis 字符串数据
$redis->set("tutorial-name", "Redis tutorial");
// 获取存储的数据并输出
echo "Stored string in redis:: " . $redis->get("tutorial-name");
?>
Mac:
下载php-redis,地址:https://nodeload.github.com/nicolasff/phpredis/zip/master
链接: https://pan.baidu.com/s/1-08Wb7TsigVa1fj9k_oByg 密码: ny9g
mv ~/Downloads/phpredis-master.zip .
unzip phpredis-master.zip -d .
cd ./phpredis-master
sudo phpize
若未安装autoconf,则会报错 $ brew install autoconf
./configure --with-php-config=`which php-config`
make
make test
sudo make install
sudo emacs /Applications/XAMPP/etc/php.ini
+++++++++++++++++++++++++++++++++
extension="redis.so"
================================
重启apahce后
php -m|grep redis
查看phpredis扩展是否开启。

test:
<?php
$redis = new Redis(); // connect
$handle = $redis->connect('127.0.0.1', 6379);
if ($handle) {
echo "Connect to server successfull".PHP_EOL;
var_dump($handle);
}
echo "Server is running: ".$redis->ping().PHP_EOL; // string
$redis->set("tutorial-name", "Redis tutorial");
echo "Stored string in redis::" .$redis->get("tutorial-name").PHP_EOL; // list
$redis->del("tutorial-list"); $a = ["Redis", "MongoDB", "MySQL"];
array_walk($a, function($item, $key, $redis) {
$redis->lpush("tutorial-list", $item);
}, $redis); $arList = $redis->lrange("tutorial-list", 0, 5);
print_r($arList);
echo PHP_EOL; // keys
$keys = $redis->keys("*");
print_r($keys);
echo PHP_EOL;
execute:
$ php connect.php
Connect to server successfull
bool(true)
Server is running: +PONG
Stored string in redis::Redis tutorial
Array
(
[0] => MySQL
[1] => MongoDB
[2] => Redis
)
Array
(
[0] => tutorial-name
[1] => myhash
[2] => foo
[3] => key
[4] => tutorial-list
)
配置php redis 扩展的更多相关文章
- Apache配置php redis扩展
1.根据phpinfo,下载redis 下载地址:注意php版本号 http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/ http://wi ...
- Ubutun 配置php redis 扩展
1.安装redis 下载:wget --no-check-certificate https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz ...
- MAC 下 安装redis 并配置 php redis 扩展
下载 redis redis-3.1.2.tgz sudo tar -xzf redis-3.1.2.tgz cd redis-3.1.2 sudo phpize grep: /usr/include ...
- 腾讯云环境配置之PHP5.6.3 + redis扩展 稳定版
腾讯云环境配置之PHP5.6.3 + redis扩展 稳定版 时间:2015-01-18 01:41来源:linux.it.net.cn 作者:IT #由于上文装过yum groupinstall ...
- redis安装和配置教程phpredis扩展安装测试
作者:zhanhailiang 日期:2014-10-16 推荐阅读: Redis持久化策略 关于Redis很多其它资料阅读 1. 下载redis-2.8.17.tar.gz:http://downl ...
- nginx + php + mysql安装、配置、自启动+redis扩展
用过了apache就想着用用nginx,网上教程其实很多,但是受服务器版本等限制,每个人遇到的问题也不一样,先记录下我的 一.安装依赖 yum -y install gcc zlib zlib-dev ...
- Linux上给php配置redis扩展
说明,在项目开发中难免会遇到redis中,那我应该如何配置redis这样的一个扩展呢,看下面流程: 一.安装Redis PHP在安装redis扩展时,难免要看一下官网下载安装流程,链接如下: http ...
- 【Redis】windows环境下安装redis服务器,并配置php的redis扩展
win7示例: 1.下载Redis服务器 : https://github.com/dmajkic/redis/downloads:(随便下,建议不要太老的) 2.在D:\phpStudy\ 新建Re ...
- mac机上搭建php56/nginx 1.8.x/thinkphp 3.2.x/gearman扩展/seaslog扩展/redis扩展环境
php的各种扩展配置起来实在不容易,记录一下备忘: 一.php56 安装 虽然php7出来了,但是没用过,不知道有没有坑,这里仍然使用php5.6版本 1.1 安装php/php-pfm brew u ...
随机推荐
- Adaptive AUTOSAR 学习笔记 15 - 持久化 Persistency
本系列学习笔记基于 AUTOSAR Adaptive Platform 官方文档 R20-11 版本 AUTOSAR_EXP_PlatformDesign.pdf.作者:Zijian/TENG 原文地 ...
- C#/VB.NET 将PDF转为OFD
OFD,全称Open Fixed-layout Document ,是一种可存储.读取以及编辑的国家标准版式的电子文档格式,属于中国的一种自主文件格式,在安全性上有可靠保证.为突破国外技术在我们软硬件 ...
- C# 通过反射实现对象映射:将2个属性相近的对象相互转换
前言 我们在编程过程中,经常需要将一个对象转成另一个对象(一般称为对象映射). 比如我们有2个类: //第1个类 CLS1 class CLS1 { public int i {get; set;} ...
- QT从入门到入土(九)——TCP/IP网络通信(以及文件传输)
引言 TCP/IP通信(即SOCKET通信)是通过网线将服务器Server端和客户机Client端进行连接,在遵循ISO/OSI模型的四层层级构架的基础上通过TCP/IP协议建立的通讯.控制器可以设置 ...
- 如何在github上传本地项目代码
首先你要在github上申请一个账号 网址:https://github.com/ 然后你要下载一个git工具 网址:https://gitforwindows.org/ 进入官网直接下载就行,下载完 ...
- SpringCloud商品服务调用方式之Ribbon
1.创建order_service项目 pom依赖 <dependency> <groupId>org.springframework.boot</groupId> ...
- Ant的使用(一)
<?xml version="1.0" encoding="UTF-8"?> <project name="projectName& ...
- 关于Mybatis中表中字段名和POJO中字段名不同的解决方法
项目结构: POJO中: package com.domain; /** * @author mzy * 定义orders表对应的实体类 */ public class Order { /** * C ...
- 解决servlet中get方式中中文乱码问题前驱(一):装饰者模式再理解
package day02; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; ...
- 安装完anaconda之后找不到启动图标
安装anaconda的过程中,选择了only me模式,安装完之后找不到启动图标,安装网上的方法: 在命令行输入 conda update menuinstconda install -f conso ...