免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1626 | 回复: 1
打印 上一主题 下一主题

[Web] 求助:nginx整合php&memcache成功,但是memcache测试失败 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-03-24 10:04 |只看该作者 |倒序浏览
问题,nginx 成功整合php,memcached也成功安装,phpinfo能看到memcache,但是用memcache测试代码测试不成功。在线急等,环境如下:

64位centos 6.6,内核版本:2.6.32-504.el6.x86_64,

php、php-fpm,版本是:5.3.3.40,通过 yum install php* 安装

memcache信息:memcached-1.4.4-3.el6.x86_64、php-pecl-memcache-3.0.5-4.el6.x86_64、libmemcached-0.31-1.1.el6.x86_64

nginx信息,也是通过 yum 安装,版本:nginx-1.6.2-23.el6.art.x86_64

可惜解析 phpinfo ,看到php信息,也能从 phpinfo 里面看到 memcache 信息,
执行 php -m | grep memcache 也能看到成功加载 memcache 模块,
执行netstat -na | grep 11211,也能看到 11211 处于监听状态,
执行 pstree | grep mem 也能 看到 memcached 服务

但是,在 nginx 下 html 目录,新建 mem.php 文件(测试memcache文件),打开页面是空白的,同目录下 php.index (phpinfo)文件,可以解析 phpinfo ,看到 php 信息。

mem.php 文件内容如下:

<?php
$mem = new Memcache;
$mem->connect("127.0.0.1", 11211);
$mem->set('key', 'This is a test!', 0, 60);
$val = $mem->get('key');
echo $val;
?>


求大神指点,问题出在哪里,谢谢!

论坛徽章:
0
2 [报告]
发表于 2015-07-25 19:50 |只看该作者
mem.php ===you this is test file have the error.
Right
<?php
    $memcache = new Memcache;
    $memcache->connect('localhost', 11211) or die ("Could not connect");
    $memcache->set('key', 'This is a henson make memcache!',0,60);
    $get_value = $memcache->get('key');
    echo $get_value;
?>
OK,my test the right, try again. hope for you have help.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP