简体   繁体   中英

How to use Memcached with PHP7?

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

However make install command was successful and created memcached.so file. 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; see here , Travis is passing.

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

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.

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

I found the only solution was to install what appears to be the PHP 5 version* with 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-get if < 16.04)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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