[英]How to use Memcached with PHP7?
I was trying to find any information about using Memcached with PHP7, but I failed. 我试图查找有关将Memcached与PHP7结合使用的任何信息,但失败了。 The only valuable information is short
Readme.md
of php-memcached repo . 唯一有价值的信息是php-memcached repo的简短
Readme.md
。
Unfortunately, its travis build failed as well as 30/126 tests on my machine. 不幸的是,它的travis构建失败,并且在我的机器上进行了30/126测试 。
However make install
command was successful and created memcached.so
file. 但是,
make install
命令成功并创建了memcached.so
文件。 Does it mean I can use this extension in production or it still has bugs and is not recommended for using? 这是否意味着我可以在生产中使用此扩展,或者它仍然存在错误,不建议使用?
I will very appreciate any advice or working solution. 我将非常感谢任何建议或可行的解决方案。
You need to use the php7
branch; 您需要使用
php7
分支; see here , Travis is passing. 看到这里 ,特拉维斯过去了。
This should be the complete set of steps to install the memcached
extension on a Debian/Ubuntu OS: 这应该是在Debian / Ubuntu操作系统上安装
memcached
扩展的完整步骤集:
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. 如果将它们安装在其他位置,则可能需要更改某些路径。
要在最新的ubuntu上安装memcached以获取最新的php,请使用:
sudo apt-get install php-memcached
对于Debian 8用户,您可以使用:
sudo apt-get install php7.0-memcached
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.4
to be precise. 我正在使用
PHP 7.0.15-0ubuntu0.16.04.4
。 PHP 7.0.15-0ubuntu0.16.04.4
,是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
* *
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.
†如果找到,则会出现错误:
[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-get
if < 16.04) ,您需要像上面的
sudo apt install memcached
一样安装memcached扩展名(如果您使用的是16.04+,如果<16.04,请使用apt-get
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.