如何在Xampp Mac上安装Memcached


How to install Memcached on Xampp Mac

我需要在XAMPP中使用Memcached,因为我需要在本地开发,到目前为止我看到的所有解决方案都不起作用。

Fatal error: Class 'Memcached' not found in /Applications/XAMPP/xamppfiles/htdocs/system/libraries/Session/drivers/Session_memcached_driver.php on line 108
A PHP Error was encountered
Severity: Error
Message: Class 'Memcached' not found
Filename: drivers/Session_memcached_driver.php
Line Number: 108
Backtrace:
//does not work, and actually i need this not the bottom one.
//keep in mind that the service is running, and everything was succesfully
//installed with brew
$this->_memcached = new Memcached();
//works
$this->_memcached = new Memcache;

这就是我的工作原理:

  1. 使用brew:安装libmemcached

    brew安装libmemcached

  2. 使用pecl:安装memcached

    • sudo/Applications/XAMPP/examplefiles/bin/pecl安装memcached

    • 当系统提示输入libmemcached目录时,按Enter键,安装程序将自动找到它
  3. 将memcached扩展名添加到php.ini文件中:

    • sudo vim/Applications/XAMPP/example-files/etc/php.ini

    • 将"extension=memcached.so"添加到文件中
  4. 重新启动Apache服务器(使用GUI或运行):

    sudo apachectl重启

  5. 使用brew:启动memcached

    brew服务启动memcached

用这些说明创造了一个要点。

找到解决方案:)

brew install libevent
brew install autoconf
brew install libmemcached
//Download the PHP version you are using and past it to:
cd /Applications/MAMP/bin/php/php5.6.7/include/php
//Configure the source with
/Applications/MAMP/bin/php/php5.6.7/include/php/configure
//go to
cd /Applications/MAMP/bin/php/php5.6.7/bin
//compile memcached
./pecl install memcached
//go back
cd ../
//Add the memcached.so extension to your php.ini file
echo -e "'n[memcached]'nextension=memcached.so" >> conf/php.ini
//start memcached server
memcached -m 24 -p 11211 -d
//restart MAMPP and thats it!