php 如何在安装了 memcached 的情况下启用 igbinary
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6830260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to enable igbinary with memcached installed first
提问by DelphiLynx
I have memcached
installed with libmemcached. Also I have installed igbinary
.
我已经memcached
安装了 libmemcached。我也安装了igbinary
.
This is my php.ini:
这是我的 php.ini:
; Directory in which the loadable extensions (modules) reside.
;extension_dir = "./"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"
extension=apc.so
apc.enabled=1
apc.shm_size=128M
extension=memcached.so
session.save_handler=memcached
session.save_path="127.0.0.1:11211"
extension=igbinary.so
session.serialize_handler=igbinary
igbinary.compact_strings=On
.
.
When I run phpinfo() i see that igbinary is enabled, but notfor memcached:
当我运行 phpinfo() 时,我看到 igbinary 已启用,但不适用于 memcached:
apc
Serialization Support php, igbinary
igbinary
igbinary support enabled
igbinary version 1.1.1
igbinary APC serializer ABI 0
Directive Local Value Master Value
igbinary.compact_strings On On
Phpinfo() about memcached:
Phpinfo() 关于 memcached:
memcached
memcached support enabled
Version 1.0.2
libmemcached version 0.51
Session support yes
igbinary support no
That last line: igbinary support
thats the question. Oddly enough, as you can see under the heading apc there is stated: Serialization Support php, igbinary
.
最后一行:igbinary support
这就是问题所在。奇怪的是,正如您在标题 apc 下看到的那样:Serialization Support php, igbinary
.
So do someone know why I cannot enable igbinary for memcached?
那么有人知道为什么我不能为memcached启用 igbinary吗?
Thanks!
谢谢!
回答by gimpe
You can check the Memcached::HAVE_IGBINARYconstant to see if your memcached extension was compiled using --enable-memcached-igbinary.
您可以检查Memcached::HAVE_IGBINARY常量以查看您的 memcached 扩展是否是使用--enable-memcached-igbinary 编译的。
Source: http://php.net/manual/en/memcached.constants.php
来源:http: //php.net/manual/en/memcached.constants.php
Memcached::OPT_SERIALIZER
Memcached::OPT_SERIALIZER
Specifies the serializer to use for serializing non-scalar values. The valid serializers are Memcached::SERIALIZER_PHP or Memcached::SERIALIZER_IGBINARY. The latter is supported only when memcached is configured with --enable-memcached-igbinary option and the igbinary extension is loaded.
Type: integer, default: Memcached::SERIALIZER_PHP.
指定用于序列化非标量值的序列化程序。有效的序列化程序是 Memcached::SERIALIZER_PHP 或 Memcached::SERIALIZER_IGBINARY。仅当使用 --enable-memcached-igbinary 选项配置了 memcached 并加载了 igbinary 扩展时,才支持后者。
类型:整数,默认值:Memcached::SERIALIZER_PHP。
Memcached::HAVE_IGBINARY
Memcached::HAVE_IGBINARY
Indicates whether igbinary serializer support is available.
Type: boolean.
指示 igbinary 序列化程序支持是否可用。
类型:布尔值。
回答by rynop
You can't enable it because PECL memcached was not built with '--enable-memcached-igbinary'
您无法启用它,因为 PECL memcached 不是使用“--enable-memcached-igbinary”构建的
PECL install does not take this as a flag, so here is how you can build pecl memcached with it (following example is on ubuntu as root)
PECL 安装不会将此作为标志,所以这里是您如何使用它构建 pecl memcached(以下示例以 root 身份在 ubuntu 上)
#if you have libmemcached-dev < 1.0.X need to run: sudo apt-get purge libmemcached-dev
apt-get install libevent-dev
pecl install igbinary
#cant do sudo pecl install memcached-2.1.0 cuz it wont let me use igbinary
#compiling manually per http://www.neanderthal-technology.com/2011/11/ubuntu-10-install-php-memcached-with-igbinary-support/
#install libmemcached v 1.0.X for pecl memcached 2.1.0
cd /tmp
libmemcached_ver="1.0.15"
wget https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz
tar xzvf libmemcached-${libmemcached_ver}.tar.gz
cd libmemcached-${libmemcached_ver}/
./configure
make
make install
cd ../
rm -r libmemcached-${libmemcached_ver}
#install memcached PECL extension
pecl_memcached_ver="2.1.0"
pecl download memcached-${pecl_memcached_ver}
tar xzvf memcached-${pecl_memcached_ver}.tgz
cd memcached-${pecl_memcached_ver}/
phpize
./configure --enable-memcached-igbinary
make
make install
cd ..
rm -r memcached-${pecl_memcached_ver}
echo "extension=igbinary.so" > /etc/php5/fpm/conf.d/igbinary.ini
echo "extension=memcached.so" > /etc/php5/fpm/conf.d/memcached.ini
#now restart your PHP server
Load up a phpinfo() page and you should now see 'igbinary support: yes' under memcached section.
加载一个 phpinfo() 页面,您现在应该在 memcached 部分下看到“igbinary support: yes”。
回答by Adolfo Abegg
If you work on a Mac and use MacPorts, you can install the php5-memcached extension with igbinary support with this command:
如果您在 Mac 上工作并使用 MacPorts,则可以使用以下命令安装具有 igbinary 支持的 php5-memcached 扩展:
sudo port install php5-memcached +igbinary
The +igbinary
specifies a variant of the php5-memcached
port.
在+igbinary
指定的变体php5-memcached
端口。
That command will install an igbinary-enabled memcached extension on your Mac.
该命令将在您的 Mac 上安装支持 igbinary 的 memcached 扩展。
You can read more about port variants here: http://guide.macports.org/#using.variants
您可以在此处阅读有关端口变体的更多信息:http: //guide.macports.org/#using.variants