1, install memcached Service and PHP extension
Apt-get Install memcached php5-memcached php5-memcache
2. Check if the memcached service is installed.
PS aux | grep memcached
You can see that the memcached is automatically started after installation. You can also view the following commands:
Netstat-tap | grep ' memcached '
3, if you need to modify the configuration file
Please go to:/etc/memcached.conf
Restart after modification
Pkill memcached
/usr/bin/memcached restart-p 11211-u nobody-l 127.0.0.1
It's best to find a shell script on the web that directly memcache start
4, the last Web server restart, Apache or Nginx fast-cgi
/etc/init.d/apache2 restart
Finally, let's take a simple example:
$mem =newmemcache;
$mem->connect ("localhost", 11211);
$mem->set (' Test ', ' Hello World ', 0,60);
echo $mem->get (' Test ');
If you can see Hello Word, it's OK.