James Akwuh
James Akwuh

Reputation: 2217

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.

Upvotes: 10

Views: 40465

Answers (4)

patrick
patrick

Reputation: 11721

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

sudo apt-get install php-memcached

Upvotes: 8

Jonathan
Jonathan

Reputation: 11494

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)

Upvotes: 0

Егор Щапов
Егор Щапов

Reputation: 89

For Debian 8 users, you can use:

sudo apt-get install php7.0-memcached

Upvotes: 5

Will
Will

Reputation: 24709

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.

Upvotes: 11

Related Questions