我正在尝试让 memcached 在 Laravel (PHP) 中的 CentOS 6.6 服务器上工作。看起来我正确安装了 memcached,因为当我输入“ps aux | grep memcached”时,我得到一个显示它正在运行的响应。
当我运行 phpinfo 时,我得到以下信息:
当我输入“php test.php”时,我什至有一个可以通过命令行工作的小脚本,但是当我尝试从浏览器访问它时它不起作用。这是脚本:
<?php
$mem = new Memcached();
$mem->addServer("127.0.0.1", 11211);
$result = $mem->get("blah");
if ($result) {
echo $result;
} else {
echo "No matching key found. I'll add that now!";
$mem->set("blah", "I am data! I am held in memcached!") or die("Couldn't save anything to memcached...");
}
?>
因此,此脚本在从命令行运行时成功缓存,但在我从浏览器运行时不缓存。有什么建议么?