简体   繁体   English

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

[英]Can I install the memcached PHP extension with PECL?

I'm having trouble installing the " memcached " PHP extension from PECL, though I can successfully installed the " memcache " extension. 我在从PECL安装“ memcached ”PHP扩展时遇到问题,尽管我可以成功安装“ memcache ”扩展。 (They are separate PHP extensions.) (它们是单独的PHP扩展。)

For example, these commands work okay: 例如,这些命令可以正常工作:

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

However, attempting to install memcached causes errors: 但是,尝试安装memcached会导致错误:

$ sudo pecl install memcached $ sudo pecl install memcached
... ...
ld: library not found for -lmemcached ld:找不到-lmemcached的库
collect2: ld returned 1 exit status collect2:ld返回1退出状态
make: *** [memcached.la] Error 1 make:*** [memcached.la]错误1
ERROR: `make' failed 错误:'make'失败了

I'm using pecl, memcached, and libmemcached from Mac Ports (macports.org) on a recent Intel Mac. 我在最近的Intel Mac上使用来自Mac Ports(macports.org)的pecl,memcached和libmemcached。 The libmemcached libraries can be found in /opt/local: libmemcached库可以在/ opt / local中找到:

/opt/local/include/libmemcached /选择/本地/包括/ libmemcached
/opt/local/include/libmemcached/libmemcached_config.h /opt/local/include/libmemcached/libmemcached_config.h
/opt/local/lib/libmemcached.2.0.0.dylib /opt/local/lib/libmemcached.2.0.0.dylib
/opt/local/lib/libmemcached.2.dylib /opt/local/lib/libmemcached.2.dylib
/opt/local/lib/libmemcached.a /opt/local/lib/libmemcached.a
/opt/local/lib/libmemcached.dylib /opt/local/lib/libmemcached.dylib
/opt/local/lib/libmemcached.la /opt/local/lib/libmemcached.la

Any idea what I may be doing wrong? 知道我可能做错了吗?

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. 这非常有效。

same situation here. 这里的情况相同。 i had to do the above, but with explicit path names (i run my php etc. out of /opt/local) 我必须做上面的,但有明确的路径名称(我运行我的PHP等/ / opt / local)

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

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). 通常这种东西在os x上使用macports非常简单,但是还没有php5-memcached包(只有一个用于较旧的memcache(没有“d”)包)。 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. 哦,我还必须安装较旧版本的libmemcached,因为最新版本没有在os x 10.5.8上为我编译。 oy! OY!

As you've seen, the new memcached extension, uses libmemcached to do the heavy lifting. 正如您所见,新的memcached扩展使用libmemcached来完成繁重的工作。 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'). 如果它是Linux,我会说你可能没有在ld.so.conf中列出/ opt / local / lib /(并运行'ldconfig')。

MaxOSX doesn't use that though. 但是MaxOSX并没有使用它。 It is, however installable from 'ports' apparently. 然而,显然可以从“港口”安装。 http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/ http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/

Well, after many tries only this solution works for me. 好吧,经过多次尝试,只有这个解决方案适合我。

  1. Install XAMPP 安装XAMPP
  2. Install brew ( https://github.com/Homebrew/homebrew/wiki/Installation ) 安装brew( https://github.com/Homebrew/homebrew/wiki/Installation
  3. $ brew $ brew
  4. install libmemcached 安装libmemcached
  5. cd /Applications/XAMPP/xamppfiles/bin/ cd / Applications / XAMPP / xamppfiles / bin /
  6. $ sudo ./pecl install memcached $ sudo ./pecl install 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 !! VOILA !!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM