Home > Backend Development > PHP7 > How to install redis extension in php7.0

How to install redis extension in php7.0

藏色散人
Release: 2023-02-17 20:36:01
Original
3143 people have browsed it

php7.0安装redis扩展的方法:首先查看自己PHP的版本;然后下载并解压redis;最后在php.ini文件中添加“extension=php_redis.dll”即可。

How to install redis extension in php7.0

本文操作环境:windows7系统、PHP7.0版,DELL G3电脑

1、查看自己PHP的版本

echo phpinfo()
Copy after login
<code style="white-space: initial"><span class="hljs-comment"><span style="font-size: 18px">查看自己的版本:</span><br/><img src="https://img.php.cn/upload/article/000/000/020/30fcdd5ec941ccda41fd0d169dbf0349-0.png" alt=""/><br/><br/><span   style="max-width:90%">VC是14,系统是64位的,所以一定要选对版本,因为这个版本我折腾了好久。<br/><br/><span style="font-family: Microsoft YaHei">2、根据自己的PHP版本、编译器的版本以及cpu</span><br/>我的是php是7.0 、VC14、X64。附上我的下载链接redis、igbinary的链接:<br/>Redis:<br/>http://windows.php.net/downloads/pecl/releases/redis/<br/></span></span></code>
Copy after login
:
Copy after login
; php_redis

extension=php_igbinary.dll

extension=php_redis.dll
Copy after login

注意:extension=php_igbinary.dll 一定要放在在 extension=php_redis.dll 的前面,否则扩展失败!!!

5、再次实行步奏1,全文搜索Redis如图:

安装扩展成功,接下来可以简单测试一下!

6、简单测试是否可以启动服务:


<?php  
//连接本地Redis服务

  $redis = new Redis();  
  $link= $redis->connect(&#39;127.0.0.1&#39;,6379);  
  echo "Connection to server successfully";  
  //查看服务是否运行

 echo "server is running:".$redis->ping();
Copy after login

运行结果如图:

链接成功!

7、存取一下数据

<?php  
//连接本地Redis服务
  $redis = new Redis();  
  $link= $redis->connect(&#39;127.0.0.1&#39;,6379);  
  //echo "Connection to server successfully";

  //查看服务是否运行

 //echo "server is running:".$redis->ping();

 //选择数据库
 $redis -> select(2);//设置
 key$redis -> set(&#39;weather&#39;,&#39;sun&#39;);
 $redis -> set(&#39;test&#39;,&#39;good&#39;);var_dump($redis -> get(&#39;test&#39;));var_dump($redis -> get(&#39;weather&#39;));?>
Copy after login

运行结果如图:

8、为了更加直观,我又下载了RedisClient:

打开可视化界面,输入如下信息:

因为没有设置密码所以不用填写。

我们刚才是往数据库db2中添加的数据,所以打开查看一下:

<code   style="max-width:90%"><span class="hljs-comment"><span style="font-size: 18px">已经存在数据库中。有了可视化界面,我们可以直接在这里添加数据。<br/><br/>补充:视图中有个语言(</span></span></code><code style="white-space: initial"><span class="hljs-comment"><span style="font-size: 18px"><em style="box-sizing: border-box; font-style: normal; color: rgba(153, 153, 153, 1); font-family: Arial, "Microsoft YaHei", "\\5FAE软雅黑", "\\5B8B体", "Malgun Gothic", Meiryo, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; text-indent: 0; text-transform: none; white-space: normal; word-spacing: 0; -webkit-text-stroke-width: 0px; background-color: rgba(255, 255, 255, 1)"><span class="skip" style="box-sizing: border-box">language</span></em>),可以切换中文和英文!<br/><br/><br/><br/>继续学习探索中...<br/></span><br/></span></code>
Copy after login

language

The above is the detailed content of How to install redis extension in php7.0. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template