Installing memcached and php extension on Mac OSX 10.9
I just wasted fair amount of time configuring memcached on my mac development machine. It should have been easy, but it was not. So I’m going to document my steps which led me to a working configuration. Some of these steps might be unnecessary.
Brew makes allot of things easy. So if you don’t have it yet. Please install:
1 |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" |
Than check if there are some issues with doctor tool:
1 |
brew doctor |
If there are errors fix them before proceeding.
I also installed xcode command line tools, go to xcode options -> open developer tools -> more developer tools. You will need to register and download command line tools for your version of OSX.
Lets start installing required libraries with brew:
1 2 3 4 5 6 |
brew install wget brew install automake brew install memcached brew install libmemcached brew tap homebrew/dupes brew install zlib |
I think memcached was automatically installed by xcode command line tools. Run:
1 |
brew doctor |
If it complains that there are parallel versions of memcached. Just do:
1 |
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile |
This will ensure that brew installed packages will be used before xcode installed ones.
Lets proceed with php extension:
1 2 3 4 5 6 |
cd /usr/local mkdir src cd src wget http://pecl.php.net/get/memcached-2.1.0.tgz tar -xzf memcached-2.1.0.tgz cd memcached-2.1.0 |
Now edit this file, if you don’t edit this files make will fail with fatal error.
1 |
vi php_libmemcached_compat.h |
And at the very end add:
1 |
typedef const struct memcached_server_st *memcached_server_instance_st; |
Lets proceed with configuration and installation:
1 2 3 4 |
phpize ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8 make sudo make install |
You will see some warnings but ignore it.
Lets enable this extension by editing php.ini:
1 |
sudo vi /etc/php.ini |
Add this line:
1 |
extension=memcached.so |
Restart apache:
1 |
sudo apachectl restart |
Now you can check if memcached extension was successfully installed by visiting info.php page
1 |
<?php phpinfo(); ?> |
You should see:
Leave a Reply