Detailed explanation of ubuntu memcached installation and configuration in php

黄舟
Release: 2023-03-15 18:28:01
Original
1085 people have browsed it


Detailed explanation of ubuntu memcached installation and configuration in php

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

Download php memcached.dll under window

Next configure PHP

Copy php_memcache.dll to the PHP extension folder, add a line

extension=php_memcache.dll
Copy after login

to the php.ini file, restart the web server, and check phpinfo. If there is memcached content, it means that the 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 Detailed explanation of ubuntu memcached installation and configuration 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