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