Installation and configuration method of ubuntu memcached in php

一个新手
Release: 2023-03-15 18:36:01
Original
1400 people have browsed it

# 安装服务端
sudo apt-get install memcached
#启动服务
memcached -d -m 128 -p 11111 -u root
Copy after login

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";
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!