douchuilai2355 2014-05-20 08:00
浏览 48
已采纳

如何在小牛队上安装memcache? (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.

I installed X-Code from appstore, and libevent, memcached, libmemcached with homebrew.

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/

After that I copied memcached.so and memcache.so to my extension_folder:

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

and added extension = memcached.so to my php.ini.

I still get fatal error.. what's the problem?

  • 写回答

1条回答 默认 最新

  • douba2705 2015-08-23 23:42
    关注

    How to install memcache and memcached on any version MAMP and on any version of php on LINUX/MAC by yourself?

    1. open a terminal
    2. install brew:

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

    1. brew install memcached

    2. brew install libmemcached

    3. start memchached (daemon) as you whish To have launchd start memcached at login:

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

    Then to load memcached now:

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

    Or, if you don't want/need launchctl, you can just run:

    /usr/local/opt/memcached/bin/memcached

    1. download the SAME !!! VERSION of php source code from php.net what you want to use with MAMP
    2. extract to /tmp
    3. configure -> make -> make install
    4. when "make install" ends you can see ON THE TERMINAL SCREEN !!! the paths where the php binary was installed on your system
    5. cd that path where your binary located
    6. pecl i memcache
    7. follow onscreen !!! instruction and copy 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

    /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;

    2. phpinfo(); and check memcached appears.

    OK ITS DONE !!! NOW -> have a beer :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵