Installing the Memcache cache

Source: Internet
Author: User
Tags memcached

Memcache Introduction: danga.com An open source project, it is a high-performance distributed memory Object cache system

The ability to store data in a variety of formats by maintaining a unified, huge hash table in memory


* View current number of memcache connections

# Netstat-n | grep:11211 | Wc-l


* See the number of connections allowed by default, the number of 11211 port default connections set here is 40960

# cat/etc/rc.local


* How to view Memcache server-side version

#./memcached-h


* Memcache installation under Linux

# CD/USR/LOCAL/SRC


Install yum extension Source: # Yum Install-y epel-release

Memcache module: # yum install-y php-pecl-memcached


Download memcache:# wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz

Download libevent:# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz


First load libevent:# tar zxvf libevent-1.2.tar.gz

# CD libevent-1.2

#./configure--prefix=/usr/local/libevent

# make

# make Install


* Test whether the libevent is installed successfully

# Ls-al/usr/local/libevent/lib | grep libevent

lrwxrwxrwx 1 root root Apr 13:01 libevent-1.2.so.1-libevent-1.2.so.1.0.3

-rwxr-xr-x 1 root root 264056 Apr 13:01 libevent-1.2.so.1.0.3

-rw-r--r--1 root root 430388 Apr 13:01 libevent.a

-rwxr-xr-x 1 root root 820 Apr 13:01 libevent.la

lrwxrwxrwx 1 root root Apr 13:01 libevent.so-libevent-1.2.so.1.0.3


Installing memcached # CD/USR/LOCAL/SRC

# yum Install-y libevent-devel

# tar ZXVF memcached-1.2.0.tar.gz

# CD memcached-1.2.0

#./configure--with-libevent=/usr/local/memcached

# make

# make Install


* Test for successful installation of memcached

# ls-al/usr/local/bin/mem*

-rwxr-xr-x 1 root root 113084 Apr 13:23/usr/local/bin/memcached

-rwxr-xr-x 1 root root 117439 Apr 13:23/usr/local/bin/memcached-debug


* Install PHP extensions for Memcache

1. In Http://pecl.php.net/package/memcache, select the version of memcache you want to download

2. Installing the PHP memcache extension


# tar ZXVF memcache-2.2.1.tgz

# CD memcache-2.2.1

#/usr/local/php5.6/bin/phpize

Running this command will generate a script and then compile the extension


#./configure--enable-memcache--with-php-config=/usr/local/php5.6/bin/php-config--with-zlib-dir

# make

# make Install


# Vim/usr/local/php5.6/etc/php.ini

Extension_dir = "/usr/local/php5.6/lib/php/extensions/no-debug-non-zts-20131226/"

Extension=memcache.so


* Basic settings for memcached

1) Start the server side of the Memcache

#/usr/local/bin/memcached-d-M 100-u root-l 127.0.0.1-p 12000-c 300-p/tmp/mem cached.pid


The-D option is to start a daemon,

-M is the amount of memory allocated to Memcache, in megabytes, I'm 10MB,

-U is the user running memcache, I am root here,

-L is the server IP address of the listener, if there are multiple addresses, I specify the server IP address 192.168.0.200,

-P is the port that sets Memcache listening, I set here 12000, preferably more than 1024 ports,


2) If you want to end the memcache process, execute:

# Kill ' Cat/tmp/memcached.pid '


3) Restart Apache,service httpd restart


4) memcache Environmental test

Run the following PHP file if there is an output of this is a test! It means the environment has been built successfully.

# cd/var/www/html

# Vim hjt.php

<?php

$mem = new Memcache;

$mem->connect ("127.0.0.1", 11211);

$mem->set (' key ', ' This is a test! ', 0, 60);

$val = $mem->get (' key ');

Echo $val;

?>


Installing the Memcache cache

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.