Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I install the memcached PHP extension with PECL?

I'm having trouble installing the "memcached" PHP extension from PECL, though I can successfully installed the "memcache" extension. (They are separate PHP extensions.)

For example, these commands work okay:

$ sudo pecl install memcache
$ sudo pecl install APC
$ sudo pecl install oauth

However, attempting to install memcached causes errors:

$ sudo pecl install memcached
...
ld: library not found for -lmemcached
collect2: ld returned 1 exit status
make: *** [memcached.la] Error 1
ERROR: `make' failed

I'm using pecl, memcached, and libmemcached from Mac Ports (macports.org) on a recent Intel Mac. The libmemcached libraries can be found in /opt/local:

/opt/local/include/libmemcached
/opt/local/include/libmemcached/libmemcached_config.h
/opt/local/lib/libmemcached.2.0.0.dylib
/opt/local/lib/libmemcached.2.dylib
/opt/local/lib/libmemcached.a
/opt/local/lib/libmemcached.dylib
/opt/local/lib/libmemcached.la

Any idea what I may be doing wrong?

like image 753
richardkmiller Avatar asked Mar 25 '09 23:03

richardkmiller


People also ask

How do I enable Memcached php?

To enable the PHP Memcache extensions, you need to build PHP utilizing –enable-Memcache option when building, and configure it from the source. On Debian-based dispersions, you can use the php-Memcache package. To set global runtime configuration choices, specify the configuration option values within your php.

What is php PECL memcache?

PHP License. Description. Memcached is a caching daemon designed especially for. dynamic web applications to decrease database load by. storing objects in memory.


2 Answers

Andrei Zmievski (developer of the memcached plugin) kindly answered my email request with the following instructions:

$ pecl download memcached
$ tar zxvf memcached-1.0.0.tgz (or whatever version downloads)
$ cd memcached-1.0.0
$ phpize
$ ./configure --with-libmemcached-dir=/opt/local
$ make
$ sudo make install

This worked perfectly.

like image 53
richardkmiller Avatar answered Oct 26 '22 10:10

richardkmiller


As you've seen, the new memcached extension, uses libmemcached to do the heavy lifting. If it were Linux, I'd say that it was possible that you don't have /opt/local/lib/ listed in ld.so.conf (and run 'ldconfig').

MaxOSX doesn't use that though. It is, however installable from 'ports' apparently. http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/

like image 44
Alister Bulman Avatar answered Oct 26 '22 11:10

Alister Bulman