PHP,Memcached的命令行工作,但不能从网络 [英] PHP, Memcached works from command line but not from the web

查看:944
本文介绍了PHP,Memcached的命令行工作,但不能从网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CentOS 6.4的 memcached.so 扩展安装了PHP 5.3.3,和httpd的与2.2.15-26版本上运行。这里是我的的index.php

I have PHP 5.3.3 installed on Centos 6.4 with the memcached.so extension, and httpd is running with version 2.2.15-26. Here is my index.php:

$mc = new \Memcached();
$mc->addServer('127.0.0.1', 11211);
$mc->set("test", "blah");
var_dump($mc->getResultCode());
var_dump($mc->getResultMessage());
var_dump($mc->get("test"));
die;

当我在命令行中运行它,它的工作原理。我得到以下几点:

When I run it from the command line, it works. I get the following:

10:22:33 $ php index.php
int(0)
string(7) "SUCCESS"
string(4) "blah"

内存缓存服务器还从工作的telnet。然而,当我运行的index.php 从Web,失败我得到以下(从查看网页源):

The memcache server also works from telnet. However, when I run index.php from the web, it fails. I get the following (from viewing webpage source):

int(47)
string(51) "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"
bool(false)

重新安装我的操作系统和尝试不同版本的废话,任何人都可以解释什么可能导致此问题短?

Short of re-installing my OS and trying different versions of crap, can anyone explain what might cause this issue?

推荐答案

它是一个的SELinux 的问题? CLI可以访问Memcached的,但没有守护进程。试试这个:

Is it an SELinux problem ? Cli can access to Memcached but daemon no. Try this :


  • getenforce 来知道你是否有将SELinux

  • 0 setenforce 来禁用它

  • 重新启动

  • 重试测试

  • getenforce to know if you have SELinux enabled
  • setenforce 0 to disable it
  • reboot
  • Retry your test

如果是好的,您必须配置Apache来访问Memcached的。

If is good, You must configure Apache to access to Memcached.

这篇关于PHP,Memcached的命令行工作,但不能从网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆