Install memcache with php 5.4.4 in MAMP PRO v2.1.1

Any wishes or suggestions for MAMP?
Post here what functions you are still missing for MAMP.

Moderator: severin

Post Reply
oceanmajk
Posts: 2
Joined: Wed 12. Dec 2012, 16:46
Contact:

Install memcache with php 5.4.4 in MAMP PRO v2.1.1

Post by oceanmajk » Wed 12. Dec 2012, 17:21

I spent a day and got pecl memcached-3.0.7 working with MAMP PRO v2.1.1 and php 5.4.4 on OSX 10.7.5. It was a real pain in the ass, so I figured I'd share how I did it. It may or may not work for you, there's a lot of dependencies to make this happen. You must have xcode and developer tools and command line tools installed, and possibly know your way around linux shell commands.

Use at your own risk.


open up terminal and create a new bash file in your home directory:

Code: Select all

vi install_memcache.sh
and copy and paste the following in there and save the file. (vi commands: i > command + v > esc > :wq)

Code: Select all

#!/bin/sh

mkdir src
cd src

# Install libevent dependency
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xfz libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure && make
sudo make install
cd ..

# Install memcached and fixes
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
tar xfz memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure && make
sudo make install

# point local php to right directory
sudo mv /usr/bin/php /usr/bin/php.bak
sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/php /usr/bin/php
sudo mv /usr/bin/phpize /usr/bin/phpize.bak
sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/phpize /usr/bin/phpize
sudo mv /usr/bin/php-config /usr/bin/php-config.bak
sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/php-config /usr/bin/php-config



# Compile php 5.4 to get proper include files
cd /Applications/MAMP/bin/php/php5.4.4/
rm -rf include
mkdir include
cd include
wget http://php.net/get/php-5.4.4.tar.gz/from/this/mirror
tar xfz php-5.4.4.tar.gz
mv php-5.4.4 php
cd php
./configure
cd ../../bin

# install memcache with php 5.4 config
sudo ./pear config-set php_ini /Applications/MAMP/conf/php5.4.4/php.ini
sudo ./pecl config-set php_ini /Applications/MAMP/conf/php5.4.4/php.ini
sudo ./pecl channel-update pecl.php.net
sudo ./pecl uninstall memcache
sudo ./pecl i memcache-3.0.7

echo

echo "copy the memcache.so file from the 20100525 directory where memcache installed above"
echo "into the MAMP directory: /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525"

#sudo cp /usr/local/lib/php/extensions/no-debug-non-zts-20100525/memcache.so /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525

echo
echo "edit your php.ini file (File -> Edit Template -> PHP -> PHP 5.4.4 php.ini), adding 'extension=memcache.so' in the Extensions section then restart MAMP"
run the install script:

Code: Select all

sh install_memcache.sh
you will be prompted for your root user password to run sudo commands



IF ALL GOES WELL
You should see the pecl memcache installer install into the 20100525 directory, like this:

Code: Select all

Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/memcache.so'
copy the memcache.so file from the 20100525 directory where memcache says it installed into the MAMP php 5.4.4 directory: /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525

something like this:

Code: Select all

sudo cp /usr/local/lib/php/extensions/no-debug-non-zts-20100525/memcache.so /Applications/MAMP/bin/php/php5.4.4/lib/php/extensions/no-debug-non-zts-20100525
then edit your php.ini file in MAMP (File -> Edit Template -> PHP -> PHP 5.4.4 php.ini), adding 'extension=memcache.so' in the Extensions section then restart MAMP

Restart or start your memcached server(s) and you should be good to go. You're welcome.



IF YOU STILL HAVE PROBLEMS
If the pecl installer says it installed into the 20090626 directory, like this:

Code: Select all

Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so'

you're still stuck using php 5.3 and need to figure out how to get phpize to run with php 5.4. Good luck with that!
Brandon Simpson
Entrepreneur · Thinker · LAMP Web Developer · Photographer
http://brandon.cc

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest