# We started pretending to be memcache
TAR-ZXVF tar-zxvf libevent-1.4.13-stable.tar.gzcd libevent-1.4.13-stable./configure--prefix=/usr make && Mak E Install # To see if libevent is complete Ls-al/usr/lib | grep libevent tar-zxvf memcached-1.4.17.tar.gz cd memcached-1.4.17./configure--with-libevent=/usr make && make Install # to see if memcache installation is complete ls-al/usr/local/bin/mem* # start Memcache server #启动Memcache的服务器端:/usr/local/bin/memcached-d-M 2 00-u www-p 11211-c 256-p/tmp/memcached.pid # (IP not specified)
#参数说明:
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 202.207.177.177,
#-p is to set the Memcache listening port, I set up here 11211, 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 here is saved in/tmp/memcached.pid,
#2. If you want to end the memcache process, execute: Kill ' Cat/tmp/memcached.pid '
# Add Firewall rule
#-I add a rule in front
# DROP Destination port 11211 for all packets iptables-i input-p TCP--dport 11211-j drop# separate packets for the current port of the specific IP iptables-i input-s 2-p TCP--dport 11211-j ACCEPT
# View the port number that was started
Netstat-tanp # View all user-enabled ports
NETSTAT-TUNP # View ports Open by current user
# Install extensions for Php-memcache
TAR-ZXVF Memcache-2.2.4.tgz
CD memcache-2.2.4
Phpize # yum-y Install php-devel
./configure If no phpize command is found --with-php-config=/usr/bin/php-config--enable-memcache # error:memcache support requires ZLIB. Use--with-zlib-dir=<dir> to specify prefix where zlib include and library is located This error will be performed:yum-y I Nstall Zlib-devel
Make
makes Test
# # to see if memcache.so
can be found in the extended directory ls/usr/lib64/php/modules/ # If not, copy a past CP modules/memcache.so/usr/lib64/php/modules/
# # # # # # # # # # # # # # # # # If you can find Reload PHP config file for testing
Service httpd Reload
# # # # # # # # # # # # # # # # # Test memcache normal
# new index.php file test see if PHP supports Memcache
<?phpini_set (' display_errors ', 1); error_reporting (7); $mem = new Memcache; $mem->connect (' 192.168.1.112 ', 11211 ); $mem->set (' Test ', ' Hello world! ', 0,12); $val = $mem->get (' test '); Echo $val; Var_dump ($val);
# If the page is output Hello world!string ("Hello world!") This means that PHP already supports the Memcache module
# #/etc/rc.d/rc.local Add memcache Start command to make sure Memcache starts automatically at boot vi/etc/rc.d/rc.local # memcache start/usr/local/bin/memcached -d-m 200-u www-p 11211-c 256-p/tmp/memcached.pid
memcached (source package) installation, PHP (RPM package)-memcache extension installation