View related Packages
Yum Search memcached
Installing Memcache
Yum-y Install memcached
Memcache Associated PHP
Yum-y Install Php-pecl-memcache
Verifying the installation Results
Memcached-h
php-m | grep memcache
Add PHP's Memcache extension
- Yum Install Php-pecl-memcache
- Yum Install Zlib-devel
- pecl Install memcache
Add "extension=memcache.so" to the PHP configuration file
Start the memcached service
Memcached-d-M 512-l 127.0.0.1-p 11211-u root (normal boot)
Memcached-d-M 10-u root-l 192.168.40.4-p 11211-c 256-p/tmp/memcached.pid (full boot)
Memcached-d-M 1024-u root-p 55001-c 2048 (default boot)
Check if memcached is started
Netstat-an | More
TCP 0 0 192.168.40.4:11211 0.0.0.0:* LIST
Start the memcached Setup boot
Chkconfig memcached on
Start and stop
Service memcached Start | Stop
or/etc/init.d/memcached Start | Stop
Re-start CentOS
Shutdown-r now
Or reboot
Parameter description:
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, and here I specify the IP address of the server 192.168.40.4;
-P is the port that sets Memcache listening, preferably a port above 1024
The-c option is the maximum number of concurrent connections to run, which is 1024 by default and is set according to the load on your server
-P is a PID file that is set to save Memcache
-VV Debug Mode
memcached Environmental Testing
Run the following PHP file, if you have output this is a memcache test!, it means that the environment to build a successful, start your memcache journey!
<? $memnew Memcache; $mem->connect ("192.168.40.4", 11211$mem->set (' key ', ' This is a memcache test! ', 0, 60 $val$mem->get (' key 'echo$val?>
This article turns from http://www.linuxidc.com/linux/2011-09/43033.htm!
Linux Installation Memcache Extended Support