How to use Memcached with PHP7?
Solution 1
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.
Solution 2
To install memcached on the latest ubuntu for the latest php use:
sudo apt-get install php-memcached
Solution 3
For Debian 8 users, you can use:
sudo apt-get install php7.0-memcached
James Akwuh
Updated on May 13, 2020Comments
-
James Akwuh almost 4 years
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 createdmemcached.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.
-
Joe Watkins about 8 yearsI fixed the travis build ... if you have bugs, report them ... there's no possible way to guess ;)
-
James Akwuh about 8 years@JoeWatkins will follow your advice in a short time, thank you
-
Joe Watkins about 8 yearsAlso, they are all experimental tests ... travis wasn't failing because of bugs in php-memcached, just bugs in the build script ... you should be fine.
-
James Akwuh about 8 years@JoeWatkins thank for notice, that's important. Does it mean that current php-memcached#php7 is not covered with tests, so can not considered to be stable?
-
Joe Watkins about 8 yearsNo, the failures you have are in tests/experimental, which are not run by CI ... they cover experimental features ...
-
Taco almost 8 yearsOne important change in the php7 version of php-memcached is the removal of the $cas_token parameter from the get methods, I've written a post about this: developer.procurios.com/post/2016/05/17/…
-
-
COil almost 7 yearsNote that the extension version installed is this case is: 3.0.3. Unfortunately I couldn't use it because it's considered as a new major version and not being supported by some old vendor libraries that check directly on the version number to initialize themselves. In this case the last version it supported was 2.2.
-
Jamie Hutber almost 7 yearsI don't understand what I am meant to do with
/usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config
/usr/local/php7/bin/phpize
does not exist. -
Oberst almost 7 years@JamieHutber: "If the system is missing the phpize command, and precompiled packages (like RPM's) are used, be sure to also install the appropriate devel version of the PHP package as they often include the phpize command along with the appropriate header files to build PHP and its extensions." -- php.net/manual/en/install.pecl.phpize.php
-
Jonathan over 6 yearsI literally have no idea why it has -1 @hegez
-
Brian Leishman over 6 yearsI upvoted, also have no idea what the downvote was for
-
Brian Leishman over 6 yearsAlso a note, at least for php 7.1 installing
php7.1-memcached
works, but it just points tophp-memcached
, at least on the Ondrej repo that I found described here blog.programster.org/debian-8-install-php-7-1 -
dani24 about 6 yearsIf a message error "No Memcached servers added" you need also to install:
sudo apt-get install memcached
and then it works! -
Hernán Eche over 5 years@JamieHutber sudo apt-get install php7.0-dev and then /usr/bin/phpize is there
-
Chris Tophski almost 5 yearsIn my Ubuntu 18.04 setup with PHP7.2 I also had to
apt-get install pkg-config zlib1g-dev
and myphp
,phpize
andphp-config
were in/usr/bin
.