分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

ubuntu 下搭建redis和php的redis的拓展

发布时间:2023-09-06 01:48责任编辑:白小东关键词:redis
系统环境:
腾讯云服务器, ubuntu16.0.4.4 ,php7.0
 
一.安装redis服务
sudo apt-get install redis-server
安装好的redis目录在 /etc/redis [也可使用命令whereis redis 查找]
启动:
sudo service redis-server start
 
然后运行客户端命令redis-cli能够出现命令提示符127.0.0.1:6379: >就算成功了!
 
二.安装redis 拓展
1.安装redis和php的redis扩展

  

apt-get install git php-dev ??//包含了phpize

  

git clone https://github.com/nicolasff/phpredis.git //克隆phpredis拓展
cd phpredis/
 phpize //生成PECL扩展的configure文件
 ./configure
 make //编译
 make install //安装
2.配置php的redis扩展
sudo vim /etc/php/7.0/fpm/php.ini 中写入 extension=redis.so
 
3.重启fpm,访问info.php,就能看到redis扩展
/etc/init.d/php7.0-fpm restart
 
4.读取测试
<?php ????$redis = new Redis();
???//连接redis服务器 ???$redis->connect(‘127.0.0.1‘, ‘6379‘)or die ("Could net connect redis server!");; ???echo "Connection to server sucessfully <br/>"; ???//查看服务是否运行 ???echo "Server is running: " . $redis->ping();

  参考链接:https://blog.csdn.net/setoy/article/details/77679976

                         https://blog.csdn.net/caoyouming0609/article/details/78197462

ubuntu 下搭建redis和php的redis的拓展

原文地址:https://www.cnblogs.com/xiaotaoing/p/8718278.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved