Configuring PHP to Use Memcached

gourmet fare

PHP and Memcached


Once you finally get memcached installed on your server, it's time to configure PHP to use it.

Since I use MAMP on my MacBook, things were a little awkward. I needed everything to be done with the specific version of PHP I was using, in this case I'm using MAMP 3.0.4, and its supplied PHP 5.5.10. So all of the "php" and "phpize" commands had to use the full path, /Applications/MAMP/bin/php/php5.5.10/bin/.

Again, following the tutorial on the Donat Studios site, everything went fairly smoothly. I installed PEAR, then downloaded and compiled the files for creating the extenstion. After a bit of searching, I finally found the file in the memcached-work directory (surprise, surprise... duh!), and moved it to the /Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/ directory. Whew! Fortunately for my fingers, I use iTerm, which supports copy/paste, and you can copy the full path from the "Get Info" window of the extensions directory.

Then it was a simple matter to add the extension to my php.ini file. Which php.ini file, you may ask? Just go to the MODX Manager's Reports, System Info, and click the "view" link for phpinfo. There you will find the "Loaded Configuration File" with the full path to your site's php.ini file.


Shut down and restart the MAMP servers, and you should now find this in your phpinfo view.

Memcached in phpinfo

Once you have your server and PHP configured to use memcached, you'll need to configure MODX to use it.