代码: wget -c http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz tar xvfz memcached-1.4.15.tar.gz cd memcached-1.4.15 ./configure --prefix=/usr/local/memcache --with-libevent=/usr make make install memcached至/etc/rc.d/init.d/ 代码: #! /bin/sh # # chkconfig: - 55 45 # description: The memcached daemon is a network memory cache service. # processname: memcached # config: /etc/sysconfig/memcached # Source function library. . /etc/rc.d/init.d/functions PORT=11211 USER=root MAXCONN=1024 CACHESIZE=256 OPTIONS="" if [ -f /etc/sysconfig/memcached ];then . /etc/sysconfig/memcached fi # Check that networking is up. if [ "$NETWORKING" = "no" ] then exit 0 fi RETVAL=0 start () { echo "Starting memcached ..." # insure that /var/run/memcached has proper permissions chown $USER /usr/local/memcache/bin/memcached /usr/local/memcache/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached.pid $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached } stop () { echo "Stopping memcached ..." killproc memcached RETVAL=$? echo if [ $RETVAL -eq 0 ] ; then rm -f /var/lock/subsys/memcached rm -f /var/run/memcached.pid fi } restart () { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status memcached ;; restart|reload) restart ;; condrestart) [ -f /var/lock/subsys/memcached ] && restart || : ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" exit 1 esac exit $? chmod +x /etc/init.d/memcached chkconfig --add memcached chkconfig --level 235 memcached on service memcached start