Ubuntu install memcached with PHP extension test use

Source: Internet
Author: User
Tags install php

1,memcached needs libevent, so install it first

: http://download.chinaunix.net/download.php?id=45065&ResourceID=5804

Tar XF libevent-2.0.21-stable.tar.gz

CD libevent-2.0.21-stable

Make

sudo make install

2, install memcached

wget http://memcached.org/files/memcached-1.5.5.tar.gz

Tar XF memcached-1.5.5.tar.gz

CD memcached-1.5.5/

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

Make && sudo make install

3, install PHP memcache extension

wget http://pecl.php.net/get/memcache-2.2.7.tgz

Tar XF memcache-2.2.7.tgz

CD memcache-2.2.7/

/usr/local/php54/bin/phpize

./configure--enable-memcache--with-php-config=/usr/local/php54/bin/php-config--with-zlib-dir

"If there is no zlib, install zlib first"

wget http://www.zlib.net/fossils/zlib-1.2.11.tar.gz

Tar XF zlib-1.2.11.tar.gz

CD zlib-1.2.11/

./configure

Make && sudo make install

And then install Memcache.

Make && sudo make install

4, add extension in php.ini

Extension=memcache.so

5, start memcached server

/usr/local/bin/memcached-d-M 10-u root-l 127.0.0.1-p 12000-c 256-p/tmp/memcached.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 IP address of the server 127.0.0.1
-P is the port that sets Memcache listening, I set here 12000, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set the 256 here, according to the load of your server to set,
-P is set to save memcache PID file, I am here to save in/tmp/memcached.pid,

6. Writing Test files

<? PHP     $mem New Memcache;     $mem->connect ("127.0.0.1", 12000 );     $mem->set ("Hi", "Hello,ghostwu", 0, + );     Echo $mem Php_eol ;? >

Ubuntu install memcached with PHP extension test use

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.