VPS侦探论坛

 找回密码
 注册
查看: 2928|回复: 1

求助 redis无法使用

[复制链接]
发表于 2017-11-7 14:34:50 | 显示全部楼层 |阅读模式

这个问题我在论坛和教程都搜索过了 好像没有找到解决方案
lnmp1.4 执行:./redis.sh 安装完成后用
第一步使用:连接不上
cat test.php
<?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");
?>
结果是Warning: Redis::connect(): connect() failed: Connection timed out in /home/XXX...

第二步:查看
ps aux | grep redis
root      3994  0.0  0.1 136928  7500 ?        Ssl  13:54   0:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root      4633  0.0  0.0 112668   980 pts/3    S+   13:58   0:00 grep --color=auto redis
第三步:重启redis
/etc/init.d/redis stop
Stopping  Redis server...


感觉卡在那了就ctrl+c结束后 kill杀掉这个进程了 kill -s 9 3994

在重新启动 /etc/init.d/redis start 就有问题了
/var/run/redis.pid exists, process is already running or crashed
试了下重启也不好使 /etc/init.d/redis restart
Stopping  Redis server...
Could not connect to Redis at 127.0.0.1:6379: Connection timed out
done
/var/run/redis.pid exists, process is already running or crashed
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-11-7 18:20:58 | 显示全部楼层

回复 1# 的帖子



你直接kill 造成pid文件没正常自动删掉,rm /var/run/redis.pid 删掉pid文件就行了

程序正常运行,连不上端口首先要检查的就应该是iptables 规则
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 03:20 , Processed in 0.025392 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表