Installing the memcached service side
Memcached relies on libevent, which requires libevent to be installed first.
Install Libevent
# tar ZXVF libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
#./configure--prefix=/usr/local/ Libevent
# make && make install
install memcached service side
# wget http://www.memcached.org/files/ memcached-1.4.20.tar.gz
# tar zxvf memcached-1.4.20.tar.gz
# cd memcached-1.4.20
#./configure- prefix=/usr/local/webserver/memcached--with-libevent=/usr/local/libevent
# make && make install
Start memcached
# cd/usr/local/webserver/memcached/
#./bin/memcached-d-M 32-u root-p 11211-c 128? P/tmp/memcached.pid
Start parameter Description:
The-D option is to start a daemon process.
-U root indicates that the user starting memcached is root.
-M is the amount of memory allocated to Memcache, in megabytes, by default 64MB.
-M return error on memory exhausted (rather than removing items).
-U is the user who is running memcache, and you need to use this parameter to specify the user if you are currently root.
-P is the port that sets the TCP listening for memcache, preferably over 1024 ports.
The-c option is the maximum number of concurrent connections to run, by default 1024.
-P is the PID file that sets the save Memcache.
PHP installation memcache Extension
memcached:http://pecl.php.net/package/memcached
Memcache:http://pecl.php.net/package/memcache
# wget HTTP://PECL.PHP.NET/GET/MEMCACHE-2.2.7.TGZ #
Tar zxvf memcache-2.2.7.tgz
# cd memcache-2.2.7 #
./ Configure--enable-memcache--with-php-config=/usr/local/webserver/php/bin/php-config--with-zlib-dir
# make && make Install
After compiling, modify php.ini add extension=memcache.so, restart PHP-FPM
PHP installation memcached Extension
# wget http://launchpadlibrarian.net/66527034/libmemcached-0.48.tar.gz
# cd libmemcached-0.48 #
./configure --prefix=/usr/local/libmemcached--with-memcached
# make && make install
Installation issues to be aware of:
1, do not forget the installation process,--with-memcached, or you will be prompted
Checking for memcached ... no
configure:error: "Could not find memcached binary"
2, your memcached is not 1.2.4 more, if not will prompt you
clients/ms_thread.o:in function ' ms_setup_thread ':
/home/zhangy/libmemcached-0.42/clients/ms_thread.c:225: Undefined reference to ' __sync_fetch_and_add_4 '
clients/ms_thread.o:/home/zhangy/libmemcached-0.42/clients/ms _thread.c:196:more undefined references to ' __sync_fetch_and_add_4 ' follow Collect2:ld returned
1 exit status
m AKE[2]: * * * [Clients/memslap] Error 1
make[2]: Leaving directory '/home/zhangy/libmemcached-0.42 '
The solution is--disable-64bit cflags= "-o3-march=i686", and if you don't use this 64-bit long data, I think the PHP extension Memcached,memcache is no different, Pretending to be a memcached is no fun.
# wget http://pecl.php.net/get/memcached-2.2.0.tgz
# cd memcached-2.2.0
#/usr/local/webserver/php/bin/ Phpize
#./configure--enable-memcached--with-php-config=/usr/local/webserver/php/bin/php-config-- with-libmemcached-dir=/usr/local/libmemcached--DISABLE-MEMCACHED-SASL
checking for sasl/sasl.h ... no
Configure:error:no, Sasl.h is not available. Run Configure with--DISABLE-MEMCACHED-SASL to disable this check
# make && make install
After compiling, modify php.ini add extension=memcached.so, restart PHP-FPM