Home >Backend Development >PHP Tutorial >Installation and configuration method of ubuntu memcached in php
# 安装服务端 sudo apt-get install memcached #启动服务 memcached -d -m 128 -p 11111 -u root
Download php memcached.dll under window
http://pecl.php.net/package/memcache/3.0.8/windows
Next configure PHP
Copy php_memcache.dll to the PHP extension folder, add a line in the php.ini file
extension=php_memcache.dll
Restart the web server, check phpinfo, if there is memcached content, it means that PHP configuration is successful.
You can use the following program to test whether the installation is successful:
header('Content-type: text/html; charset=utf-8'); $memcache = memcache_connect('192.168.0.156', 11111); if ($memcache) { $memcache->set("str_key", "String to store in memcached"); $memcache->set("num_key", 123); $object = new StdClass; $object->attribute = 'test'; $memcache->set("obj_key", $object); $array = Array('assoc'=>123, 345, 567); $memcache->set("arr_key", $array); var_dump($memcache->get('str_key')); var_dump($memcache->get('num_key')); var_dump($memcache->get('obj_key')); }else { echo "Connection to memcached failed"; }
The above is the detailed content of Installation and configuration method of ubuntu memcached in php. For more information, please follow other related articles on the PHP Chinese website!