phpapachemamphomebrewlibmemcache

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.

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?


Solution

  • 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 :)