Install PHP memcached extension on macOS - Prador

  [ Rocketeers ](/)   

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

 On this page

 Knowledge
---------

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

### [\#Development](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/development)

 Published by [Mark van Eijk](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/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.

On a fresh Mac you'll also need the [Xcode command line tools](/install-xcode-command-line-tools) installed before you can build PHP extensions.

### 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://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/development)

- [How to rename a Git branch (local and remote)](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/git-rename-branch)
- [git reset --hard explained (soft vs mixed vs hard)](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/git-reset-hard)
- [How to checkout a Git tag](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/git-checkout-tag)
- [docker exec: run a command in a running container](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/docker-exec)
- [How to clean up Docker with prune (images, volumes, system)](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/docker-prune)
- [How to remove untracked files in Git (git clean)](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/git-remove-untracked-files)

 [View all 13 articles →](https://3c80d338-d724-4b4e-9f6d-145bb1e3d26e.rocketeers.cloud/development)
