Install Memcache and PHP memcache extensions under Cenos.

Source: Internet
Author: User

I. Installing the Memcahce
1. Install the dependency pack libevent
Memcache needs to be installed libevent, so you may need to do it before installing

Shell Code
    1. Yum Install Libevent-devel


2. Installing Memcache
Download the latest version of 1.4.13 from http://memcached.org/

Shell Code
    1. TAR-XZVF memcached-1.4. 13.tar.gz
    2. CD memcached-1.4. -
    3. ./configure--prefix=/usr/local/memcache
    4. Make && make install


3. Configure memcached self-boot
Copy the source directory under Scripts/memcached.sysv to/etc/init.d/memcached, you need to modify the/etc/init.d/memcached line as follows:

Shell Code
    1. Chown $USER/usr/local/memcache/bin/memcached
    2. Daemon/usr/local/memcache/bin/memcached-d-P $PORT-u $USER-M $CACHESIZE-C $MAXCONN-P/VAR/RUN/MEMCACHED/MEMCACHED.P ID $OPTIONS


(Just modify the path of memcached)

Then execute the following command:

Shell Code
    1. chmod 755 memcached
    2. Chkconfig--add memcached



Start try

Shell Code
    1. Service memcached Start



II. Installing the PHP memcahce extension

The reference pecl.php.net has two memcache extensions:
Memcache memcached Extension
memcached PHP extension for interfacing with memcached via Libmemcached Library


The memcached version is newer and uses the Libmemcached library. Libmemcached is thought to have done a better job of optimizing, and should have a higher performance than PHP only version of Memcache. So the installation here is memcached (assuming php5.4 is already installed in/usr/local/php).
1. Installing Dependent libraries
Https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz

Shell Code
    1. TAR-XZVF libmemcached-1.0. 4.tar.gz
    2. CD libmemcached-1.0. 4
    3. ./configure
    4. Make
    5. Make install


2. Installing memcached
http://pecl.php.net/get/memcached-2.0.1.tgz Download, installation instructions:

Shell Code
    1. Tar vxzf memcached-2.0. 1.tgz
    2. CD memcache-2.0. 1
    3. Phpize
    4. ./configure--enable-memcache--with-php-config=/usr/local/php/bin/php-config
    5. Make
    6. Make install


After loading, the final display installing shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/, Generate the memcached.so in this directory, and copy it to the directory that php.ini Extension_dir points to. Modify php.ini Add Line Extension = memcached.so restart Apache, and then go to the page to open the Phpinfo information page to see if the memcached extension was installed successfully.

Write a test to see

PHP code
    1. <?php
    2. $m = new Memcached ();
    3. $m->addserver (' localhost ', 11211);
    4. $m->set (' username ', ' Allen ');
    5. Var_dump ($m->get (' username '));
    6. ?>



There is also a PHP written memcache monitoring tool that can be downloaded
http://livebookmark.net/journal/2008/08/28/memcachephp-flushes-servers/
This article is how to set PHP session to Memcache
http://koda.iteye.com/blog/466667

Go from blog->http://koda.iteye.com/blog/665761

Install Memcache and PHP memcache extensions under Cenos.

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.