Memcached requires libevent support, so you need to first check to see if Libevent is installed.
The following is the memcached installation process:
# tar zvxf memcached-1.4.9.tar.gz
# CD memcached-1.4.9
#./configure--prefix=/usr/local/memcached
# make
# make Install
Start memcached:
#/usr/local/memcached/bin/memcached-d-M 128-l 127.0.0.1-p 11211-u Root
Parameter 128 Specifies the amount of memory used
The next step is to install Memcache extensions for PHP:
# gzip-d Memcache-2.2.6.tgz
# tar XVF Memcache-2.2.6.tar
# CD memcache-2.2.6
#/usr/local/php/bin/phpize
#./configure--with-php-config=/usr/local/php/bin/php-config--enable-memcache
# make
# make Install
Finally, add the following configuration information to the php.ini file:
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
Extension=memcache.so
Remark:/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/This path may be different, whichever is the same in your machine.
Memcached has been installed in Linux and is deployed to the/usr/local/memcached path, next we start to install service management scripts for it to start and stop.
First of all, through VI in the/ETC/RC.D/INIT.D path to create a new script file named memcached, the command is as follows:
Vi/etc/rc.d/init.d/memcached
Then, write the shell script to it as follows:
#!/bin/sh
#
# chkconfig:2345 90 50
# description:memcached Service Daemon
#
# processname:memcached
#
# 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 0
Memcached= "/usr/local/memcached/bin/memcached"
Start ()
{
Echo-n $ "Starting Memcached:"
Daemon $MEMCACHED-u daemon-d-M 32-l 127.0.0.1-p 11211-c 256-p/tmp/memcached.pid
Echo
}
Stop ()
{
Echo-n $ "Shutting down Memcached:"
Killproc memcached
Echo
}
[f $MEMCACHED] | | Exit 1
# How we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Restart)
Stop
Sleep 3
Start
;;
*)
echo $ "Usage: $ {Start|stop|restart}"
Exit 1
Esac
Exit 0
After saving exit VI, execute the following command to install the script
chmod 777/etc/rc.d/init.d/memcached
Chkconfig--add memcached
Chkconfig--level 235 memcached on
You can then check to see if the installation was successful by using the following command
Chkconfig--list | grep memcached
Service memcached Start
Service memcached Stop
Service memcached Restart