Install PHP memcached extension on macOS - Rocketeers app

  [ Rocketeers ](/)   

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

 On this page

 Knowledge
---------

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

### [\#Development](https://rocketeersapp.com/knowledge/development)

 Published by [Mark van Eijk](https://rocketeersapp.com/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://rocketeersapp.com/knowledge/development)

- [git stash pop vs apply: save and restore changes](https://rocketeersapp.com/knowledge/git-stash-pop)
- [npm ci vs npm install: when to use which](https://rocketeersapp.com/knowledge/npm-ci-vs-npm-install)
- [How to delete a local (and remote) Git branch](https://rocketeersapp.com/knowledge/git-delete-local-branch)
- [docker compose up: options and common flags](https://rocketeersapp.com/knowledge/docker-compose-up)
- [How to checkout a Git tag](https://rocketeersapp.com/knowledge/git-checkout-tag)
- [What port does SSH use (and how to change it)](https://rocketeersapp.com/knowledge/ssh-port)

 [View all 13 articles →](https://rocketeersapp.com/knowledge/development)
