Install PHP memcached extension on macOS - Rocketeers

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com) 

 On this page

 Knowledge
---------

Install PHP memcached extension on macOS
========================================

### [\#Development](https://rocketee.rs/index.php/development)

 Published by [Mark van Eijk](https://rocketee.rs/index.php/author/mark-van-eijk) on March 17, 2023 · 1 minute read

1. [Install using Homebrew and PECL](#content-install-using-homebrew-and-pecl)
2. [ZLIB path](#content-zlib-path)

[\#](#content-install-using-homebrew-and-pecl "Permalink")Install using Homebrew and PECL
-----------------------------------------------------------------------------------------

If you have PHP installed using [Homebrew](https://brew.sh), you previously could also install PHP extensions using `brew` itself. But things have changed, and you need to use `pecl` to install additional extensions.

When you need to install `memcached`, you need to install this including the dependencies `zlib` and `libmemcached`:

 ```
brew install memcached libmemcached zlib pkg-config

```

Then you can initiate the install via `pecl`:

 ```
pecl install memcached

```

This will ask multiple questions, where you will only need to answer the question about the path of zlib:

 ```
zlib directory [no] :

```

This path depends on the processor of your Mac, there's a difference between Apple silicon machines on Mac Intel. The path is per type of machine:

[\#](#content-zlib-path "Permalink")ZLIB path
---------------------------------------------

 ```
# On Apple Silicon
/opt/homebrew/opt/zlib

# On Mac Intel
/usr/local/opt/zlib

```

When given this path, the `pecl` install should complete successfully.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Development](https://rocketee.rs/index.php/development)

- [How to delete a local (and remote) Git branch](https://rocketee.rs/index.php/git-delete-local-branch)
- [Fix: Cannot connect to the Docker daemon at unix:///var/run/docker.sock](https://rocketee.rs/index.php/cannot-connect-to-docker-daemon)
- [git stash pop vs apply: save and restore changes](https://rocketee.rs/index.php/git-stash-pop)
- [How to clean up Docker with prune (images, volumes, system)](https://rocketee.rs/index.php/docker-prune)
- [What port does SSH use (and how to change it)](https://rocketee.rs/index.php/ssh-port)
- [How to checkout a Git tag](https://rocketee.rs/index.php/git-checkout-tag)

 [View all 12 articles →](https://rocketee.rs/index.php/development)
