Source installation memcached and PHP memcache extensions

Source: Internet
Author: User
Tags perl script
Source installation memcached and PHP memcache extensions

Note: The following installation steps take the centos6.5 system as an example.

First, pre-installation preparation

1. Download the source package

http://www.memcached.org/

Currently the latest version is http://www.memcached.org/files/memcached-1.4.24.tar.gz

2, Installation Libevent

Because Memcached relies on the Libevent library, it needs to be installed Libevent
#yum Install libevent Libevent-devel

Second, installation memcached

1. Create memcached Users

#useradd-D/var/run/memcached/-s/sbin/nologin-c "memcached daemon" memcached

2. Unzip the source package

#tar ZXVF memcached-1.4.24.tar.gz

3. Compile and install

#cd memcached-1.4.24
#./configure--prefix=/usr/local/memcached
#make && make Install

4, memcached commonly used parameter description

-M memcache Maximum available memory (in m)
-U user
-L Listening IP
-P Port number

Third, add service script

#vi/etc/rc.d/init.d/memcached

The contents are as follows

#! /bin/sh
#
# Chkconfig:-55 45
# description:the memcached Daemon is a network memory cache service.
# processname:memcached
# config:/etc/sysconfig/memcached
# Pidfile:/var/run/memcached/memcached.pid

# Standard LSB functions
#. /lib/lsb/init-functions

# Source function library.
. /etc/init.d/functions

ip=127.0.0.1
port=11211
User=memcached
maxconn=1024
Cachesize=64
Options= ""

# Check that networking are up.
. /etc/sysconfig/network

If ["$NETWORKING" = "No"]
Then

Exit 0

Fi

Retval=0
Prog= "Memcached"
Pidfile=${pidfile-/var/run/memcached/memcached.pid}
Lockfile=${lockfile-/var/lock/subsys/memcached}

Start () {

Echo-n $ "Starting $prog:" # ensure that/var/run/memcached has proper permissionsif ["' Stat-c%u/var/run/memcached '"! = "$USER"]; Then    chown $USER/var/run/memcachedfidaemon--pidfile ${pidfile}  /usr/local/memcached/bin/memcached-d-l $IP  -  P $PORT-u $USER-  m $CACHESIZE-C $MAXCONN-P ${pidfile} $OPTIONSRETVAL =$?echo[$RETVAL-eq 0] && Touch ${lockfile}

}
Stop () {

Echo-n $ "Stopping $prog:" Killproc-p ${pidfile}/usr/local/memcached/binretval=$?echoif [$RETVAL-eq 0]; Then    rm-f ${lockfile} ${pidfile}fi

}

Restart () {

    Stop    Start

}

# See how we were called.
Case "$" in
Start

start;;

Stop

stop;;

Status

Status-p ${pidfile} memcachedretval=$?;;

Restart|reload|force-reload)

restart;;

Condrestart|try-restart)

[-F ${lockfile}] && Restart | | :;;

*)

echo $ "Usage: $ Start|stop|status|restart|reload|force-reload|condrestart|try-restart}" retval=2    ;;

Esac

Exit $RETVAL

Iv. Testing

1. Start memcached Service

#/etc/rc.d/init.d/memcached start
Default memcached service Listener in 127.0.0.1:11211

2. Testing

#telnet 127.0.0.1 11211

Input stats, normal display as follows, indicating the successful installation

Trying 127.0.0.1 ...
Connected to 127.0.0.1.
Escape character is ' ^] '.
Stats
STAT PID 12246
STAT Uptime 2444
STAT Time 1442302696
STAT version 1.4.24
STAT libevent 2.0.22-stable
STAT Pointer_size 64
STAT Rusage_user 0.089986
STAT Rusage_system 0.027995
STAT curr_connections 5
STAT Total_connections 7

STAT Connection_structures 6

V. Installation of Memcached-tool Tools

Memcached-tool is a memcached monitoring tool that is a Perl script that can be run directly. The command usage is as follows.

Usage:memcached-tool [mode]

   Memcached-tool 10.0.0.5:11211 Display    # shows slabs   memcached-tool 10.0.0.5:11211            # same.  (default is Display)   Memcached-tool 10.0.0.5:11211 Stats      # shows general stats   Memcached-tool 10.0.0.5:11211 dump       # dumps keys and values

Vi. Installation of PHP memcache extensions

1. Download the source package

Memcache-3.0.8.tgz

2. Install memcache Extension

#tar ZXVF memcache-3.0.8.tgz
#cd memcache-3.0.8
#/usr/local/php/bin/phpize
#./configure--with-php-config=/usr/local/php/bin/php-config
#make && make Install

3. Modify the configuration file php.ini

Add extension=memcache.so

4. Testing

Restarting Nginx and php-fpm, viewing phpinfo () displays the following information indicating that the installation was successful.

Registered Save handlers Files user Memcache

Memcache Support Enabled

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.