简体   繁体   English

如何在小牛队上安装memcache? (MAMP)

[英]How to install memcache on Mavericks? (MAMP)

I have MAMP on my machine, and I would like to install memcache for php, because one of my project throws errors like Fatal error: Class 'Memcache' not found . 我的机器上有MAMP,我想为php安装memcache,因为我的一个项目会抛出Fatal error: Class 'Memcache' not found

I installed X-Code from appstore, and libevent , memcached , libmemcached with homebrew . 我从appstore安装了X-Code ,用homebrew安装了libeventmemcachedlibmemcached

Then.. 然后..

cd /tmp; pecl download memcached
gzip -d < memcached-2.2.0.tgz | tar -xvf -
cd memcached-2.2.0; phpize
./configure; make
sudo make install

Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20100525/ 安装共享扩展:/ usr / lib / php / extensions / no-debug-non-zts-20100525 /

After that I copied memcached.so and memcache.so to my extension_folder: 之后我将memcached.so和memcache.so复制到我的extension_folder:

/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/ /Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/

and added extension = memcached.so to my php.ini. 并将extension = memcached.so添加到我的php.ini中。

I still get fatal error.. what's the problem? 我仍然会致命的错误..问题是什么?

How to install memcache and memcached on any version MAMP and on any version of php on LINUX/MAC by yourself? 如何在任何版本的MAMP和LINUX / MAC上的任何版本的PHP上自行安装memcache和memcached?

  1. open a terminal 打开一个终端
  2. install brew: 安装brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )" ruby -e“$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )”

  1. brew install memcached brew安装memcached

  2. brew install libmemcached brew install libmemcached

  3. start memchached (daemon) as you whish To have launchd start memcached at login: 你想要启动memchached(守护进程)要在登录时启动memcached:

ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents ln -sfv /usr/local/opt/memcached/*.plist~/ Library / LaunchAgents

Then to load memcached now: 然后立即加载memcached:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist launchctl load~ / Library / LaunchAgents / homebrew.mxcl.memcached.plist

Or, if you don't want/need launchctl, you can just run: 或者,如果您不想/需要launchctl,您可以运行:

/usr/local/opt/memcached/bin/memcached 在/ usr /本地的/ opt /分布式缓存/斌/ memcached的

  1. download the SAME !!! 下载相同!!! VERSION of php source code from php.net what you want to use with MAMP 来自php.net的PHP源代码版本 ,您想要与MAMP一起使用
  2. extract to /tmp 提取到/ tmp
  3. configure -> make -> make install configure - > make - > make install
  4. when "make install" ends you can see ON THE TERMINAL SCREEN !!! 当“make install”结束时,你可以在终端屏幕上看到!!! the paths where the php binary was installed on your system 您的系统上安装php二进制文件的路径
  5. cd that path where your binary located cd你的二进制文件所在的路径
  6. pecl i memcache pecl i memcache
  7. follow onscreen !!! 按照屏幕显示! instruction and copy memcache.so 指令和复制memcache.so
  8. if no instruction, which I doubt it then locate YOUR VERSION of php extensions directory/no-debug-non-zts... or copy memcache.so to here on MAC 如果没有指令,我怀疑它然后找到你的版本的PHP扩展目录/ no-debug-non-zts ...或复制memcache.so到这里MAC

/Applications/MAMP/bin/php/ [PHP VERSION YOU USE!!!] /lib/php/extensions/no-debug-non-zts-20060613 / Applications / MAMP / bin / php / [PHP VERSION YOU USE !!!] / lib / php / extensions / no-debug-non-zts-20060613

  1. add to php.ini (the same version you downloaded and using with mamp) this line: extension=memcache.so; 添加到php.ini (您下载并与mamp一起使用的版本)此行:extension = memcache.so;

  2. phpinfo(); 的phpinfo(); and check memcached appears. 并检查memcached出现。

OK ITS DONE !!! 好的,完成! NOW -> have a beer :) 现在 - >喝啤酒:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM