我可以使用 PECL 安装 memcached PHP 扩展吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/683864/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:29:37  来源:igfitidea点击:

Can I install the memcached PHP extension with PECL?

phpmacosmemcachedpecl

提问by richardkmiller

I'm having trouble installing the "memcached" PHP extension from PECL, though I can successfully installed the "memcache" extension. (They are separate PHP extensions.)

我在从 PECL安装“ memcached” PHP 扩展时遇到问题,但我可以成功安装“ memcache”扩展。(它们是单独的 PHP 扩展。)

For example, these commands work okay:

例如,这些命令可以正常工作:

$ sudo pecl install memcache
$ sudo pecl install APC
$ sudo pecl install oauth

$ sudo pecl 安装内存缓存
$ sudo pecl 安装 APC
$ sudo pecl 安装 oauth

However, attempting to install memcached causes errors:

但是,尝试安装 memcached 会导致错误:

$ sudo pecl install memcached
...
ld: library not found for -lmemcached
collect2: ld returned 1 exit status
make: *** [memcached.la] Error 1
ERROR: `make' failed

$ sudo pecl install memcached
...
ld:未找到 -lmemcached
collect2 的库:ld 返回 1 退出状态
make:*** [memcached.la] 错误 1
错误:`make'失败

I'm using pecl, memcached, and libmemcached from Mac Ports (macports.org) on a recent Intel Mac. The libmemcached libraries can be found in /opt/local:

我在最近的 Intel Mac 上使用来自 Mac Ports (macports.org) 的 pecl、memcached 和 libmemcached。可以在 /opt/local 中找到 libmemcached 库:

/opt/local/include/libmemcached
/opt/local/include/libmemcached/libmemcached_config.h
/opt/local/lib/libmemcached.2.0.0.dylib
/opt/local/lib/libmemcached.2.dylib
/opt/local/lib/libmemcached.a
/opt/local/lib/libmemcached.dylib
/opt/local/lib/libmemcached.la

/opt/local/include/libmemcached
/opt/local/include/libmemcached/libmemcached_config.h
/opt/local/lib/libmemcached.2.0.0.dylib
/opt/local/lib/libmemcached.2.dylib
/opt/local /lib/libmemcached.a
/opt/local/lib/libmemcached.dylib
/opt/local/lib/libmemcached.la

Any idea what I may be doing wrong?

知道我可能做错了什么吗?

回答by richardkmiller

Andrei Zmievski (developer of the memcached plugin) kindly answered my email request with the following instructions:

Andrei Zmievski(memcached 插件的开发者)用以下说明回复了我的电子邮件请求:

$ pecl download memcached
$ tar zxvf memcached-1.0.0.tgz (or whatever version downloads)
$ cd memcached-1.0.0
$ phpize
$ ./configure --with-libmemcached-dir=/opt/local
$ make
$ sudo make install

This worked perfectly.

这工作得很好。

回答by Alister Bulman

As you've seen, the new memcached extension, uses libmemcached to do the heavy lifting. If it were Linux, I'd say that it was possible that you don't have /opt/local/lib/ listed in ld.so.conf (and run 'ldconfig').

正如您所见,新的 memcached 扩展使用 libmemcached 来完成繁重的工作。如果是 Linux,我会说您可能没有在 ld.so.conf 中列出 /opt/local/lib/(并运行“ldconfig”)。

MaxOSX doesn't use that though. It is, however installable from 'ports' apparently. http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/

MaxOSX 不使用它。但是,它显然可以从“端口”安装。http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/

回答by Paul

same situation here. i had to do the above, but with explicit path names (i run my php etc. out of /opt/local)

这里的情况相同。我必须执行上述操作,但是使用显式路径名(我从 /opt/local 运行我的 php 等)

  • /opt/local/bin/pecl download memcached
  • tar zxvf memcached-1.0.0.tgz
  • cd memcached-1.0.0
  • /opt/local/bin/phpize
  • ./configure --prefix=/opt/local --with-php-config=/opt/local/bin/php-config--with-libmemcached-dir=/opt/local
  • make
  • make install
  • /opt/local/bin/pecl 下载 memcached
  • tar zxvf memcached-1.0.0.tgz
  • cd memcached-1.0.0
  • /opt/local/bin/phpize
  • ./configure --prefix=/opt/local --with-php-config=/opt/local/bin/php-config--with-libmemcached-dir=/opt/local
  • 制作
  • 进行安装

normally this kind of stuff is pretty simple on os x with macports, but there is no php5-memcached package yet (only one for the older, memcache (no "d") package). oh, an i also had to install an older version of libmemcached, since the latest version didn't compile on os x 10.5.8 for me. oy!

通常这种东西在带有 macports 的 os x 上非常简单,但是还没有 php5-memcached 包(只有一个用于较旧的 memcache(无“d”)包)。哦,我还必须安装旧版本的 libmemcached,因为最新版本无法在 os x 10.5.8 上编译。哎呀!

回答by Oskar Hasinski

Well, after many tries only this solution works for me.

好吧,经过多次尝试,只有这个解决方案对我有用。

  1. Install XAMPP
  2. Install brew (https://github.com/Homebrew/homebrew/wiki/Installation)
  3. $ brew
  4. install libmemcached
  5. cd /Applications/XAMPP/xamppfiles/bin/
  6. $ sudo ./pecl install memcached
  1. 安装 XAMPP
  2. 安装 brew ( https://github.com/Homebrew/homebrew/wiki/Installation)
  3. $ 酿造
  4. 安装 libmemcached
  5. cd /应用程序/XAMPP/xamppfiles/bin/
  6. $ sudo ./pecl 安装 memcached

Build process completed successfully Installing '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/memcached.so' install ok: channel://pecl.php.net/memcached-2.2.0 configuration option "php_ini" is not set to php.ini location You should add "extension=memcached.so" to php.ini

构建过程成功完成安装 '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/memcached.so' install ok: channel://pecl.php.net/memcached-2.2。 0 配置选项“php_ini”未设置为 php.ini 位置您应该将“extension=memcached.so”添加到 php.ini

VOILA !!

瞧!