Preparation of a compilation environment
Yum install gcc
Two, source package preparation
wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
Three, installation and configuration
1, installation Libevent
Tar zxvf libevent-1.4.14b-stable.tar.gzcd libevent-1.4.14b-stable./configure--prefix=/usr/local/libevent/make && make Installln-s/usr/local/libevent/lib/libevent-1.4.so.2/lib/libevent-1.4.so.2
2, installation memcached
Tar zxvf memcached-1.4.15.tar.gzcd memcached-1.4.15./configure--prefix=/usr/local/memcached/--with-libevent=/usr/ Local/libevent/make && make Install
3. Start memcached
/usr/local/memcached/bin/memcached-d-M 64-u root-l 127.0.0.100-p 11211-c 128-p/tmp/memcached.pid
4, in order to facilitate management, write a shell script.
# http://blog.phpha.com# The following excerpt from the Internet vi/etc/rc.d/init.d/memcached#!/bin/sh## memcached:memcached daemon# chkconfig:- 25# description:memcached daemon# Source function Library: /etc/rc.d/init.d/functions. /etc/sysconfig/network#[${networking} = "No"] && exit 0#[-r/etc/sysconfig/dund] | | Exit 0#. /etc/sysconfig/dund#[-Z "$DUNDARGS"] && exit 0start () {echo-n $ "starting memcached:" Daemon $MEM Cached-u daemon-d-M 64-l 127.0.0.100-p 11211-c 128-p/tmp/memcached.pid echo}stop () {echo-n $ "Shutti ng down memcached: "Killproc memcached echo}memcached="/usr/local/memcached/bin/memcached "[-F $MEMCACHED] || Exit # See how we were Called.case "$" in start) start; stop) stop;; Restart) Stop sleep 3 start; *) echo $ "Usage: $ Start|stop|restart}" Exit 1esacexit 0
5. Add memcached Boot
Cd/etc/rc.d/init.d/chmod 777 Memcachedchkconfig--add memcachedchkconfig--level 235 memcached onchkconfig--list | grep memcached
6, memcached use
Service memcached startservice memcached stopservice memcached Restart
iv. php installation memcache extension (memcache and memcached extension Two select one, it is recommended to install the following memcached)
[root~] wget-c http://pecl.php.net/get/memcache-3.0.8.tgz[root~] TAR-ZXVF memcache-3.0.8.tgz[root~] CD Memcache-3.0.8[root~]/usr/local/php/bin/phpize[root~]./configure --with-php-config=/usr/local/php/bin/ Php-config--enable-memcache--with-zlib-dir[root~] make && make install/usr/local/php/lib/php/extensions/ No-debug-non-zts-20121212/memcache.so[root~] Vim/usr/local/php/etc/php.iniextension =/usr/local/php/lib/php/ Extensions/no-debug-non-zts-20121212/memcache.sosession.save_handler = Memcachesession.save_path = "tcp:// 127.0.0.100:11211 "[root~] service PHP-FPM Reload
php5.5+ version of the Memcache extension installation method:
Because the php5.5+ version has a built-in memcache extension, you do not need to download a third-party plugin to do the following directly cd/usr/local/php/bin./pecl install Memcache will prompt for session support. Enter no or yes as required, after the installation path is as follows:/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ Memcache.so needs to be manually configured into php.ini, which means that the memcache extension is enabled by adding the following: extension=memcache.so
Supplement: PHP memcache extension after installation found a problem, session will appear lost, which may be installed memcached server, when the firewall does not add 11211 port, after modifying firewall rules, everything is OK.
v. Installation of PHP memcached extensions (Note that this is memcached non-memcache)
wget HTTPS://LAUNCHPAD.NET/LIBMEMCACHED/1.0/1.0.16/+DOWNLOAD/LIBMEMCACHED-1.0.16.TAR.GZTAR-ZXVF libmemcached-1.0.16.tar.gz CD libmemcached-1.0.16./configure--prefix=/usr/local/libmemcached--with-memcachedmake && make install wget http://pecl.php.net/get/memcached-2.2.0.tgztar zxvf MEMCACHED-2.2.0.TGZCD Memcached-2.2.0/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make Installvi/usr/local/php/etc/php.ini plus extension=memcached.so re-start the service.
Vi. Several methods of using Memcache synchronization session for PHP project distribution
1, directly modify the php.ini configuration file
Session.save_handler = Memcachesession.save_path = "tcp://127.0.0.100:11211"
2. Use the. htaccess file under the directory
Php_value Session.save_handler "memcache" Php_value Session.save_path "tcp://127.0.0.1:11211"
3. Modify the configuration in the project
Ini_set ("Session.save_handler", "Memcache"), Ini_set ("Session.save_path", "tcp://127.0.0.100:11211");
Above is just a few simple instructions, generally do distributed is the server permissions, so recommend the first