当前位置:首页 » 编程语言 » phprediswindow

phprediswindow

发布时间: 2023-08-08 11:43:23

① windows10 怎么安装php redis扩展

Warning: ssh2_connect(): Unable to connect to .. 此类提示是在新版本中代码规范新增了 ”@“符号,调用方法是需开头加"@"
以下为样例:

window 安装
php ssh2扩展安装
php
ssh2
方法/步骤
1. 下载 php extension ssh2根据自己PHP的版本去下载
2. 解压完后,会有三个文件,libssh2.dll、php_ssh.dll、php_ssh2.pdb。
3. 将 php_ssh.dll、php_ssh2.pdb 放到你的 php 扩展目录下 php/ext/ 下。
4. 将libssh2.dll 复制到 c:/windows/system32 和 c:/windows/syswow64 各一份
5. php.ini中加入 extension=php_ssh2.dll
6. 重启apache,即可使用php执行ssh连接操作了。
测试代码

② 怎么安装redis PHP扩展,windows下

1、首先到相应网站下载redis:

下载完成后解压到任意盘符如:D:/redis

里面包括:如图所示。

redis-server.exe:服务程序

redis-check-mp.exe:本地数据库检查

redis-check-aof.exe:更新日志检查

redis-benchmark.exe:性能测试,用以模拟同时由N个客户端发送M个 SETs/GETs 查询 (类似于 Apache 的ab 工具).

当然还需要一个:redis.conf(具体内容网上随便搜都会有)

8、PHP代码测试

$redis = new Redis();

$redis->connect("192.168.138.2","6379"); //php客户端设置的ip及端口

//存储一个 值

$redis->set("say","Hello World");

echo $redis->get("say"); //应输出Hello World

//存储多个值

$array = array('first_key'=>'first_val',

'second_key'=>'second_val',

'third_key'=>'third_val');

$array_get = array('first_key','second_key','third_key');

$redis->mset($array);

var_mp($redis->mget($array_get));

③ php redis如何使用

开始在 PHP 中使用 Redis 前,要确保已经安装了 redis 服务及 PHP redis 驱动,且你的机器上能正常使用 PHP。
PHP安装redis扩展
/usr/local/php/bin/phpize #php安装后的路径
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
修改php.ini文件
vi /usr/local/php/lib/php.ini
增加如下内容:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
安装完成后重启php-fpm 或 apache。查看phpinfo信息,就能看到redis扩展。
连接到 redis 服务
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping();
?>
执行脚本,输出结果为:
Connection to server sucessfully
Server is running: PONG
Redis PHP String(字符串) 实例
<?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:: " . jedis.get("tutorial-name");
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis:: Redis tutorial
Redis PHP List(列表) 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//存储数据到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
// 获取存储的数据并输出
$arList = $redis->lrange("tutorial-list", 0 ,5);
echo "Stored string in redis:: "
print_r($arList);
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis::
Redis
Mongodb
Mysql
Redis PHP Keys 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
// 获取数据并输出
$arList = $redis->keys("*");
echo "Stored keys in redis:: "
print_r($arList);
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list

④ windows怎么连接虚拟机上的redis

1、首先确保虚拟机redis安装成功并可以在单独蔽蠢扰虚拟机上进行set get存取值

2、本机连接虚拟机redis,确保虚拟机redis的 6379对外打开
启动档清iptables

modprobe ip_tables
iptables -A INPUT -p tcp -i eth0 --dport 6379 -j ACCEPT

如果没有iptables 可先进行安装升宏旦级 apt-get

sudo apt-get install iptables

3、windows下安装phpredis模块 (注,本次用的php5.3 并且扩展是vc9编译的)

⑤ windows php使用redis怎么后台运行

1. 进入 DOS窗口
2. 在进入Redis的安装目录
3. 输入:redis-server --service-install redis.windows.conf --loglevel verbose ( 安装redis服务 )
4. 输入:redis-server --service-start ( 启动服务 )
5. 输入:redis-server --service-stop
主要是需要安装redis的服务,电脑重新启动之后如果redis的服务没启动需要手动启动

⑥ 在php中 为什么不能使用redis类

redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)和zset(有序集合)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。
Redis 是一个高性能的key-value数据库。redis的出现,很大程度补偿了memcached这类keyvalue存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。它提供了Python,Ruby,Erlang,PHP客户端,使用很方便。
若想在PHP中使用redis,首先要先安装redis。然后在PHP中配置扩展。
安装redis。
首先下载好redis安装文件,解压到D盘或其他盘。
然后通过Dos命令行进行安装。
把这个文件夹复制到其它地方,比如D:\redis 目录下。
打开一个cmd窗口 使用cd命令切换目录到D:\redis 运行 redis-server.exe redis.conf
如果想方便的话,可以把redis的路径加到系统的环境变量里,这样就省得再输路径了,后面的那个redis.conf可以省略,如果省略,会启用默认的。
这时候另启一个cmd窗口,原来的不要关闭,不然就无法访问服务端了
切换到redis目录下运行 redis-cli.exe -h 127.0.0.1 -p 6379

这时候,就已经完成配置了。
完成了配置之后,要在PHP中添加redis的扩展,之后才可以用PHP灵活的使用它。
在windows下安装php的redis扩展非常简单,下载一个.dll扩展包放到php的ext目录下,在php.ini里边添加一行配置就可以了。

php代码测试

redis=newRedis();redis->connect(‘127.0.0.1′,6379);
redis−>set(‘test′,′helloworld!′);echoredis->get(‘test’);

输出hello world!

热点内容
华为平板怎么储存服务器文件 发布:2025-02-06 12:49:21 浏览:481
php查询结果数组 发布:2025-02-06 12:31:05 浏览:716
怎样把照片压缩打包 发布:2025-02-06 12:15:19 浏览:498
如何编译java文件 发布:2025-02-06 12:05:58 浏览:237
九九乘法编程 发布:2025-02-06 12:05:05 浏览:519
台式机忘记开机密码怎么办 发布:2025-02-06 11:58:01 浏览:871
android刷新按钮 发布:2025-02-06 11:57:17 浏览:586
存储过程有输入参数和输出参数 发布:2025-02-06 11:55:32 浏览:99
成绩评选算法 发布:2025-02-06 11:42:51 浏览:997
数据库测试数据 发布:2025-02-06 11:31:05 浏览:824