使用自制软件安装后如何启用 memcached PHP 扩展?

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

How to enable the memcached PHP extension after installing with homebrew?

phpmacosmemcachedhomebrew

提问by MacMac

I recently installed memcached with homebrew, I'm not entirely sure how to enable it on my PHP envirionment since I added extension=memcached.soin /etc/php.iniin Lion OS X.

我最近用homebrew安装了 memcached ,我不完全确定如何在我的 PHP 环境中启用它,因为我在 Lion OS X 中添加extension=memcached.so/etc/php.ini它。

Even I restarted apache too, nothing is still loaded.

即使我也重新启动了 apache,仍然没有加载任何内容。

If I call get_loaded_extensions(), I do not see memcached in the list, how can I enable it when installed from homebrew?

如果我调用get_loaded_extensions(),我在列表中看不到 memcached,从自制软件安装时如何启用它?

EDIT:

编辑:

What I did in Terminal was:

我在终端所做的是:

$ brew install memcached

$ brew install memcached

It installed just fine, now I went to /etc/php.iniand appended:

它安装得很好,现在我去了/etc/php.ini并附加:

extension=memcached.so

extension=memcached.so

采纳答案by hakre

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so'

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so'

That's the information PHP is giving you, stick to it.

这就是 PHP 给你的信息,坚持下去。

It's either:

它是:

  • The file you have specified does not exists. Check your file-system.
  • The file you've specified can not be read by PHP, check the rights of the file.
  • The file you've specified is incompatible with your PHP binary. Check if you have compiled the right sources and compilation went well.
  • 您指定的文件不存在。检查您的文件系统。
  • PHP 无法读取您指定的文件,请检查该文件的权限。
  • 您指定的文件与您的 PHP 二进制文件不兼容。检查您是否编译了正确的源代码并且编译进行得很顺利。

回答by aleemb

Install Memcached:

安装内存缓存:

# lists all memcached related packages
brew search memcached

# install memcached as well as memcached extension for PHP
brew install memcached
brew install php54-memcached

# start memcached daemon with 24MB on port 11211 (default)
memcached -d -m 24 -p 11211

Add to your php.inifile to add:

添加到您的php.ini文件以添加:

extension=memcached.so

Restart php or php5-fpm and your server. Verify:

重新启动 php 或 php5-fpm 和您的服务器。核实:

php -i | grep memcached
# should show memcached version, etc.

回答by jmontross

Install:

安装:

brew install memcached
OR
sudo pecl install memcached

Add this line to /etc/php.ini:

将此行添加到 /etc/php.ini:

extension = memcached.so
OR
extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so"

If you are having trouble finding where it lives do

如果你很难找到它的住所

mdfind memcached.so -name
=> /usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so

Make sure it is running as a daemon (-d):

确保它作为守护程序运行 (-d):

/usr/local/bin/memcached -d

Restart apache:

重启阿帕奇:

sudo apachectl restart

回答by Eric

You'll need to install libmemcached with homebrew, not just memcached. Do this:

您需要使用自制软件安装 libmemcached,而不仅仅是 memcached。做这个:

brew install libmemcached

Then try recompiling your memcache PHP module. Should be good to go

然后尝试重新编译您的 memcache PHP 模块。应该可以去

回答by yegor256

First, install memcached library with:

首先,使用以下命令安装 memcached 库:

sudo pecl install memcached

Then, add this line to /etc/php.ini:

然后,将此行添加到/etc/php.ini

extension = memcached.so

That's it.

就是这样。

回答by dsandrade

In Mac OS X El Capitan you can use

在 Mac OS X El Capitan 中,您可以使用

brew install homebrew/php/php55-memcached

回答by Saurav

You can install the memcache.so module the following way:

您可以通过以下方式安装 memcache.so 模块:

brew install memcached-php

(Note the above is currently broken if you don't have the right Xcode version)

(请注意,如果您没有正确的 Xcode 版本,则上述内容目前已损坏)

Then go to your php.ini file and add the following (Replace VERSION with the correct value):

然后转到您的 php.ini 文件并添加以下内容(将 VERSION 替换为正确的值):

extension="/usr/local/Cellar/memcached-php/VERSION/memcached.so"

Then restart apache:

然后重启apache:

sudo apachectl restart

If you can't figure out which php.ini file is being used, try calling the phpinfo() command. It will tell you exactly which php.ini file it's using.

如果您无法确定正在使用哪个 php.ini 文件,请尝试调用 phpinfo() 命令。它会准确地告诉您它正在使用哪个 php.ini 文件。

回答by Mandeep Gill

It's a 2016 so just try :

这是 2016 年,所以试试吧:

brew search memcached

You will find result and install what version of php you are using.

您将找到结果并安装您正在使用的 php 版本。

Don't know if someone else still looking for this :)

不知道还有没有人在找这个:)