【发布时间】:2016-10-27 05:41:13
【问题描述】:
我在 ubuntu 16 中使用 PHP-7 和 MySQL 安装了 memcached,我的 Web 应用程序在我使用 PHP-5 安装 xampp 的 Windows 中。
我想在 Windows 中的 Web 应用程序中使用安装在 ubuntu 中的 memcached。
有可能吗?
【问题讨论】:
标签: php mysql windows ubuntu memcached
我在 ubuntu 16 中使用 PHP-7 和 MySQL 安装了 memcached,我的 Web 应用程序在我使用 PHP-5 安装 xampp 的 Windows 中。
我想在 Windows 中的 Web 应用程序中使用安装在 ubuntu 中的 memcached。
有可能吗?
【问题讨论】:
标签: php mysql windows ubuntu memcached
您需要使用addServer 方法将您的服务器添加到memcached 服务器池。
<?php
$m = new Memcached();
$m->addServer('UBUNTU_SERVER_IP', 11211);
?>
更多信息请查看 PHP 手册中的Memcached::addServer
【讨论】:
Fatal error: Class 'Illuminate\Cache\Memcache' not found
Memcached,以d结尾吗?
PHP 手册中的示例:
<?php
$m = new Memcached();
/* Add 2 servers, so that the second one
is twice as likely to be selected. */
$m->addServer('mem1.domain.com', 11211, 33);
$m->addServer('mem2.domain.com', 11211, 67);
?>
更多信息: PHP:Memcached
在此之后不要忘记更改 /etc/memcached.conf (Ubuntu)
# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
-l 127.0.0.1
到
-l 0.0.0.0
然后
/etc/init.d/memcached restart
【讨论】: