Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install php-redis extension on mac os 10.13?

For a few days I'm trying to install php-redis extension.

Try use brew and getting this...

$ brew install php71-redis
Error: No available formula with the name "php71-redis" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

Trying to install with PECL and getting this...

    $ sudo pecl install redis
    downloading redis-4.1.0.tgz ...
    Starting to download redis-4.1.0.tgz (220,774 bytes)
    ..............................................done: 220,774 bytes
    25 source files, building
    running: phpize
    Configuring for:
    PHP Api Version:         20160303
    Zend Module Api No:      20160303
    Zend Extension Api No:   320160303
   ************

   ************
    checking whether to enable igbinary serializer support... yes
    checking whether to enable lzf compression... yes
    checking use system liblzf... no
    checking for igbinary includes... configure: error: Cannot find igbinary.h
    ERROR: `/private/tmp/pear/install/redis/configure --with-php-config=/usr/bin/php-config --enable-redis-igbinary=нуы --enable-redis-lzf=yes' failed

and finally trying to install igbinary.h ....

$ sudo pecl install igbinary
downloading igbinary-2.0.7.tgz ...
Starting to download igbinary-2.0.7.tgz (73,523 bytes)

   ************

   ************


Build process completed successfully
Installing '/usr/include/php/ext/igbinary/igbinary.h'
ERROR: failed to mkdir /usr/include/php/ext/igbinary
like image 351
Kondratenko Maxim Avatar asked Jul 12 '18 13:07

Kondratenko Maxim


1 Answers

I just did this on Mac OS 10.13 (I'm still using High Sierra).

With homebrew php7.2 and up, pecl is now installed by default alongside the php binaries.

To see this for yourself type which pecl.

Steps to install

  1. Check your version of redis, then find a suitable version of the extension here.

  2. If unfamiliar with pecl, type pecl to see the options.

  3. Issue pecl install redis 5.0.2. (or your version). Enter no to each question asked if you're not sure.

  4. If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so

  5. The install will have added extension="redis.so" to top of your php ini. Check that by opening the file /usr/local/etc/php/7.3/php.ini. (assuming you're on 7.3 there)

  6. brew services restart php.

  7. php -i | grep Redis

Redis Support => enabled
Redis Version => 5.0.2

Did this in September 2019 and it works for me.

like image 160
mwal Avatar answered Sep 21 '22 20:09

mwal