One: Install Memcache
1: Compile and install Libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
TAR-ZXVF libevent-2.0.21-stable.tar.gz
CD libevent-2.0.21-stable
./configure--prefix=/usr/local/libevent
Make
Make Isntall
2: Compile and install memcached
wget http://www.memcached.org/files/memcached-1.4.19.tar.gz
TAR-ZXVF memcached-1.4.19.tar.gz
CD memcached-1.4.19
./configure-with-libevent=/usr/local/libevent/-prefix=/usr/local/memcached
Make
Make install
3: Start memcached:
/usr/local/memcached/bin/memcached-d-M 64-u root-p 11211
The following is the memcached command-related parameter details:
The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, 10MB,
-U is the user running memcache, this is root,
-L is the server IP address that is listening, and if there are multiple addresses, this specifies the server's IP address 192.168.0.200,
-P is the port that sets the Memcache listener, which is set to 12000, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, set 256 here, according to the load of the server to set,
-P is the set to save memcache PID file, I am here to save in/tmp/memcached.pid, can also start multiple daemons, but the port can not repeat.
PS aux |grep memcached
Clipboard
Vim/etc/rc.d/rc.local join/usr/local/memcached/bin/memcached-d-M 64-u root-p 11211 #加入开机启动项
Telnet 127.0.0.1 11211 #检测memcache
If-bash:telnet:command not found appears (description does not have Telnet installed)
Direct Yum Install Telnet
Telnet set for testing
Set corresponding to the parameter
Key key is used to find cached values
Flags can include integer parameters for key-value pairs that the client uses to store additional information about key-value pairs
Expiration time length in seconds for which key value pairs are saved in the cache (0 for Forever)
Bytes The byte points stored in the cache
Value stored (always in the second row)
Clipboard1
II: Installing memcache PHP Extensions
wget http://pecl.php.net/get/memcache-3.0.8.tgz
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
Ll/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so # to see if the extension so file is generated
-rwxr-xr-x 1 root root 422219 May 9 10:29/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so #文件存在
Vim/usr/local/php/etc/php.ini #加入扩展
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
Extension = "memcache.so"
Reboot PHP:
I'm using Nginx.
KILL-USR2 ' Cat/usr/local/php/var/run/php-fpm.pid ' #平滑重启php
/usr/local/php/bin/php-m #查看php是否加入了memcache扩展 (or perform phpinfo function to see if memcache extension exists)
There are already memcach extensions, done!