代码:
<?php
ini_set('display_errors','On');
error_reporting(E_ALL);
$obj = new Redis();
$rs = $obj->connect('127.0.0.1', 6379, 20);
$obj->set('test','hello andy');
echo $obj->get('test');
apache浏览器端(我一开始没意识到浏览器端和shell端的区别,我是后来有人提到seliunx的问题才发现的)运行报错如下:
Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in /var/www/html/test.php:7 Stack trace: #0 /var/www/html/test.php(7): Redis->set('test', 'hello andy') #1 {main} thrown in /var/www/html/test.php on line 7
客户端shell运行正常:
[dev@LAMP1 html]$ php test.php
hello andy[dev@LAMP1 html]$
谢谢这位博客提供的资料: