Home >Backend Development >PHP Tutorial >Debian installs memcached and php5-memcache modules
Please support for more: http://www.webyang.net/Html/web/article_171.html
1. Install memcached service and php extension
apt-get install memcached php5-memcached php5-memcache
2. View Check whether the memcached service is installed
ps aux | grep memcached
You can find that memcached starts automatically after installation. You can also view it with the following command:
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 is best to find a shell script on the Internet, you can directly memcache start
4. Finally, restart the web server, fast-cgi of apache or nginx
/etc/init.d/apache2 restart
Finally, let’s take a simple example:
<ol> <li value="1"> <span>$mem </span><span>=</span><span></span><span>new</span><span></span><span>Memcache</span><span>;</span> </li> <li> <span>$mem</span><span>-></span><span>connect</span><span>(</span><span>"localhost"</span><span>,</span><span></span><span>11211</span><span>);</span> </li> <li> <span>$mem</span><span>-></span><span>set</span><span>(</span><span>'test'</span><span>,</span><span>'hello world'</span><span>,</span><span>0</span><span>,</span><span>60</span><span>);</span> </li> <li> <span>echo $mem</span><span>-></span><span>get</span><span>(</span><span>'test'</span><span>);</span> </li> </ol>
If you can see the hello word, it’s really ok.
The above introduces the Debian installation of memcached and php5-memcache modules, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.