Apache Can';我不能让Memcache工作
我刚刚在OS X Mountain Lion上的XAMPP中安装了Memcache,并尝试使用以下方式运行它:Apache Can';我不能让Memcache工作,apache,memcached,xampp,Apache,Memcached,Xampp,我刚刚在OS X Mountain Lion上的XAMPP中安装了Memcache,并尝试使用以下方式运行它: $memcache = new Memcache(); $memcache>connect('127.0.0.1', 11211) or die ("Could not connect"); 这将返回: Fatal error: Class 'Memcache' not found in /Applications/XAMPP/xamppfiles/htdocs/mysite
$memcache = new Memcache();
$memcache>connect('127.0.0.1', 11211) or die ("Could not connect");
这将返回:
Fatal error: Class 'Memcache' not found in /Applications/XAMPP/xamppfiles/htdocs/mysite/myfile.php on line 123
我能做些什么来解决这个问题
我使用
在我的php.ini文件中,我有extension=“memcache.so”
在phpinfo.php中,我有
mod\u mem\u cache
首先,检查语法是否正确。
您提交的示例代码中缺少指针。"->".
此外,我无法使用“或死”来检查连接是否成功,
因此,我通常检查连接对象本身
$memcache = new Memcache();
$memcache->connect('127.0.0.1', 11211);
if ($memcache === FALSE){
echo 'Unable to connect to memcache';
}
如果这不起作用,请检查是否确实有memcache可用。
在OSX上打开终端并运行:
php --info | grep '^memcache'
我尝试了你的代码,但仍然是相同的错误。错误指向这样一行:
$memcache=newmemcache()
我还尝试运行了php--info | grep'^memcache'
,但没有返回任何结果。没什么。那么我很确定你没有安装memcache(或memcached)库。请参阅上面提到的XAMPP的安装手册。您是否重新启动了Apache实例以加载所做的更改?(指南中也提到)我在XAMPP文件夹中搜索memcache,找到了一个包含两个文件的文件夹:example.php
和memcache.php
。我将memcache.php
文件移动到我的项目目录中,导入它并运行您建议的代码。现在出现一个弹出窗口,需要我的用户名和密码才能登录Memcache。我没有设置任何用户名或密码,默认值是什么?