Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install memcached module for [email protected] on MacOS High Sierra?

I have the issue installing a memcached's module for php 7.1. I use MacOS High Sierra and [email protected] installing using homebrew. During the installation of memcached module for php using command

pecl install memcached

I received the errors:

checking for zlib location... configure: error: memcached support requires ZLIB. Use --with-zlib-dir= to specify the prefix where ZLIB headers and library are located ERROR: `/private/tmp/pear/install/memcached/configure --with-php-config=/usr/local/opt/[email protected]/bin/php-config --with-libmemcached-dir' failed

But I have installed zlib. I can't find a way how to install memcached module after the changes in homebrew repository.

like image 784
alexius Avatar asked May 30 '18 09:05

alexius


People also ask

How do I enable Memcached php?

To enable the PHP Memcache extensions, you need to build PHP utilizing –enable-Memcache option when building, and configure it from the source. On Debian-based dispersions, you can use the php-Memcache package. To set global runtime configuration choices, specify the configuration option values within your php.

Where is php on mac?

ini location or use the default A typical default location on macOS is /usr/local/php/php.


2 Answers

You can use env variable PHP_ZLIB_DIR to tell it where zlib is.

PHP_ZLIB_DIR=/usr/local/opt/zlib pecl install memcached

Full installation.

brew install zlib
yes no | PHP_ZLIB_DIR=$(brew --prefix zlib) pecl install memcached
like image 144
Kamil Dziedzic Avatar answered Sep 21 '22 23:09

Kamil Dziedzic


  1. pecl bundle memcached
  2. Change to the directory it output
  3. phpize
  4. Make sure libmemcached and zlib are installed (brew install libmemcached zlib)
  5. Get the zlib directory (brew list zlib)
  6. ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/ (replace the zlib path with the one from the previous command)
  7. make
  8. make install
  9. Add the extension line in your php.ini file (ex. change the paths to match what make install output. I added this to my /usr/local/etc/php/7.4/conf.d directory in a file called ext-memcached.ini

[memcached] extension=memcached.so

  1. Verify you installed the module php -m should show you memcached in the outputted list
like image 24
Ryan Matthews Avatar answered Sep 22 '22 23:09

Ryan Matthews