Skip to content

Instantly share code, notes, and snippets.

@Niteshvgupta
Last active March 1, 2023 02:15
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Niteshvgupta/1832ce29dee460b64d5384e4f585e7ab to your computer and use it in GitHub Desktop.
Save Niteshvgupta/1832ce29dee460b64d5384e4f585e7ab to your computer and use it in GitHub Desktop.
Install PHP7-compatible memcache on Mac OS X

1. Install PHP7 with brew

brew install php70

2. Install Memcache from source on PHP7 branch

git clone -b NON_BLOCKING_IO_php7 https://github.com/websupport-sk/pecl-memcache.git
cd pecl-memcache
phpize
./configure
make && make install

3. Add the Memcache extension to the php.ini for PHP7

vi /usr/local/etc/php/7.0/php.ini

Add extension=memcache.so under the extensions section.

@shrestharoshan
Copy link

getting PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php70/7.0.14_7/lib/php/extensions/no-debug-non-zts-20151012/memcache.so' - dlopen(/usr/local/Cellar/php70/7.0.14_7/lib/php/extensions/no-debug-non-zts-20151012/memcache.so, 9): image not found in Unknown on line 0

@kowap
Copy link

kowap commented Mar 23, 2017

I have a problem. (Mac OS)
`➜ pecl-memcache git:(NON_BLOCKING_IO_php7) git clone -b NON_BLOCKING_IO_php7 https://github.com/websupport-sk/pecl-memcache.git
Cloning into 'pecl-memcache'...
remote: Counting objects: 1879, done.
remote: Total 1879 (delta 0), reused 0 (delta 0), pack-reused 1879
Receiving objects: 100% (1879/1879), 445.79 KiB | 523.00 KiB/s, done.
Resolving deltas: 100% (1308/1308), done.
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) ✗ cd pecl-memcache
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

➜ pecl-memcache git:(NON_BLOCKING_IO_php7) ./configure
zsh: no such file or directory: ./configure
➜ pecl-memcache git:(NON_BLOCKING_IO_php7) make && make install
make: *** No targets specified and no makefile found. Stop.`

@Oliboy50
Copy link

it works for php7.1 too, thanks 👍

@f4eyq
Copy link

f4eyq commented Jun 15, 2017

Hi Niteshvgupta,

Tnx for your work, i've installed it here :

=> debian 8.8, PHP : 7.0.20-1~dotdeb+8.1

And it work !

Tnx,

@healdev
Copy link

healdev commented Jan 19, 2018

Hey guys, anyone tried to install this with OS X High Sierra?

Getting the following in command "phpize":
grep: /usr/include/php/main/php.h: No such file or directory grep: /usr/include/php/Zend/zend_modules.h: No such file or directory grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory Configuring for: PHP Api Version: Zend Module Api No: Zend Extension Api No:
Then getting this on command "./configure":
checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking whether cc understands -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-apple-darwin17.3.0 checking host system type... x86_64-apple-darwin17.3.0 checking target system type... x86_64-apple-darwin17.3.0 checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20160303 checking for PHP installed headers prefix... /usr/include/php checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... no checking for nawk... no checking for awk... awk checking if awk is broken... no checking whether to enable memcache support... yes, shared checking whether to enable memcache session handler support... yes checking for the location of ZLIB... no checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
And of course "make && make install" not working...
make: *** No targets specified and no makefile found. Stop.

@david-blanchard
Copy link

@healdev,

You should try the homebrew php installation, then install the memcached extension

for me it was :
brew install php72-memcached

nothing more to do.

I hope it helps

@markhughes
Copy link

@david-blanchard memcached and memcache are different

@derkjn
Copy link

derkjn commented Apr 5, 2018

This doesn't seem to work on php7.2, plus now brew has removed/changed the way php is distributed. Additional modules now should be pulled via pecl, which in my case doesn't work at all. I'm pretty stuck 😄

@vdroznik
Copy link

vdroznik commented Apr 9, 2018

Works with new brew distribution scheme. Tested with php@7.0

@lexthor
Copy link

lexthor commented Jan 22, 2019

thank you! it worked on php 7.1

@Manyaka
Copy link

Manyaka commented Aug 12, 2019

php 7.3.7
make: *** No targets specified and no makefile found. Stop.

@Jekins
Copy link

Jekins commented Jan 13, 2020

php 7.2
make: *** No targets specified and no makefile found. Stop.
Help plz

@muhaimincs
Copy link

is there any solid steps for PHP 7.3

@travisdetert
Copy link

Why does installing this seem to break with every single php release on MacOS? I've had to update this nearly every time.

@adampatterson
Copy link

adampatterson commented Feb 16, 2021

I am on macOS 11.1

If you get the following after running phpize:

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

Then run brew install autoconf from this Stack Overflow post

I then got an error:

checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located

So I ran brew install zlib which at first did not fix the error.

I ran the command with the zlib path ./configure --with-zlib-dir=/usr/local/opt/zlib

@NewZeal
Copy link

NewZeal commented Apr 1, 2022

For those getting make: *** No targets specified and no makefile found. Stop. Check that zlib was present when running ./configure. If not then the second answer here works: https://stackoverflow.com/questions/29726890/pecl-install-memcache-fails-on-os-x-yosemite-with-memcache-support-requires-zli

Follow the instructions for installing zlib and run ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 making sure you have the same version of zlib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment