php 如何在 PHP7 中使用 Memcached?

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

How to use Memcached with PHP7?

phpmysqlperformancememcachedphp-7

提问by James Akwuh

I was trying to find any information about using Memcached with PHP7, but I failed. The only valuable information is short Readme.mdof php-memcached repo.
Unfortunately, its travis buildfailed as well as 30/126 testson my machine.

我试图找到有关在 PHP7 中使用 Memcached 的任何信息,但我失败了。唯一有价值的信息是短Readme.mdPHP-memcached的回购
不幸的是,它的travis 构建失败了,并且在我的机器上进行了30/126 次测试

However make installcommand was successful and created memcached.sofile. Does it mean I can use this extension in production or it still has bugs and is not recommended for using?

但是make install命令成功并创建了memcached.so文件。这是否意味着我可以在生产中使用此扩展程序,或者它仍然存在错误并且不建议使用?

I will very appreciate any advice or working solution.

我将非常感谢任何建议或可行的解决方案。

回答by Will

You need to use the php7branch; see here, Travis is passing.

你需要使用php7分支;看到这里,特拉维斯路过。

This should be the complete set of steps to install the memcachedextension on a Debian/Ubuntu OS:

这应该是在memcachedDebian/Ubuntu 操作系统上安装扩展的完整步骤:

sudo apt-get update
sudo apt-get install -y libmemcached-dev libmemcached11 git build-essential

git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
git pull

/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config

make
sudo make install

You may need to change some of the paths if you have them installed at different locations.

如果将某些路径安装在不同的位置,则可能需要更改它们。

回答by patrick

To install memcached on the latest ubuntu for the latest php use:

要在最新的 ubuntu 上安装 memcached 以使用最新的 php:

sudo apt-get install php-memcached

回答by Егор Щапов

For Debian 8 users, you can use:

对于 Debian 8 用户,您可以使用:

sudo apt-get install php7.0-memcached

回答by Jonathan

I came to this question via an issue with getting artisan to work in the Laravel Lumen framework.

我是通过让工匠在 Laravel Lumen 框架中工作的问题来解决这个问题的。

I'm using PHP 7. PHP 7.0.15-0ubuntu0.16.04.4to be precise.

我正在使用 PHP 7.PHP 7.0.15-0ubuntu0.16.04.4准确地说。

I found the only solution was to install what appears to be the PHP 5 version* with memcached:

我发现唯一的解决方案是安装带有 memcached 的 PHP 5 版本* :

sudo apt install memcached php-memcached

sudo apt install memcached php-memcached



*

*

php-memcached/xenial,now 2.2.0-51-ge573a6e+2.2.0-2build2 amd64 [installed]
  memcached extension module for PHP5, uses libmemcached

If you find you then get the error: [RuntimeException] Could not establish Memcached connection., you need to install the memcached extension as the above sudo apt install memcached(if you're on 16.04+, use apt-getif < 16.04)

如果你发现你然后得到错误:[RuntimeException] Could not establish Memcached connection.,你需要像上面一样安装 memcached 扩展sudo apt install memcached(如果你在 16.04+ 上,使用apt-getif < 16.04)