tags:

views:

1365

answers:

2

Hello, I cannot for the life of me figure out how I can enable memcache on Mac OSX to work w/ apache. I have installed memcache and can verify that it is working via the php command line.

The following command:

php --ri memcache

reports that memcache is supported.

However, if I load a local test script that executes phpinfo() in my browser, it does not report that memcahe is installed. Running a script in my browser that instantiates a new memcache object reports:

Fatal error: Class ‘Memcache’ not found

I have edited php.ini and added extensions=memcache.so

I have restarted apache by going to System Preferences->Sharing and disabling and enabling Web Sharing. I have even tried restarting apache from the command line w/ sudo apachectl restart.

What could I be missing that is preventing php from recognizing memcache when executed through the browser?

Thanks!

A: 

What are you using memcache for? How are you initiating it? Have you got memcached running on the machine as well?

This is not specifically a mac answer, but hopefully it will set you along the run route, apologies if this is covering the obvious.

You need memcached running either on the mac or on another machine that the mac can access on the memcached port.

There is a specific doc here on memcached on Mac - http://memcached.darwinports.com/

Remember you also need to configure php to use memcache for whatever you want memcache to cache, e.g. change the relevant PHP settings, for example using memcache to handle sessions:

session.save_handler = files
change to:
session.save_handler = memcache

session.save_path="tcp://:11211?persistent=1&weight=1&timeout=1&retry_interval=2"

Hopes this helps in some way.

http://www.of-networks.co.uk

earthgecko
thanks, but i'm looking for an answer that specifically addresses my mac osx issue. i believe i am missing a configuration somewhere in either apache or php. on my production servers, which are running ubuntu, i have successfully installed memcached for both command line and web use.
Hi HalbetApparently comments can only be 600 characters (not good if you ramble). Trying to add another answer.
earthgecko
A: 

Hi Halbert

You will probably have the memcache.so extension installed in a */no-debug-non-zts-* directory which is sometimes painful (same on Linux) and the php.ini may not look in this directory. You can either change the extensions directory in you php.ini (which may break other things) or better create a symlink to the memcache.so file in the */no-debug-non-zts-* dir.

In my case, this was:

ln -s /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so /usr/lib64/php/modules/memcache.so

Further to this check the permissions on the memcache.so file and ensure it is executable (755), in my case, this was:

chmod 755 /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so

Hope that helps and that is my last suggestion :)

http://www.of-networks.co.uk

earthgecko