Redis Installation

1. Download and install Redis

Copy/paste the following code block into your terminal.

# Downloading latest

# Extracting
tar xvzf redis-stable.tar.gz

# Changing to folder
cd redis-stable

# Installing

Optional: test if it works:

make test

Now move redis to a global place:

# Moving "redis-server" to local usr
sudo cp src/redis-server /usr/local/bin/

# Moving "redis-cli" to local usr
sudo cp src/redis-cli /usr/local/bin/

# Removing the remaining "redis-stable" folder
rm -rf ../redis-stable *

We assume that /usr/local/bin is in your PATH environment variable so that you can execute both the binaries without specifying the full path.

2. Connecting “redis” to PHP (and “MAMP”)

Error: Attempted to load class “Redis” from the global namespace.

Redis is installed in step one. But that doesn’t mean that MAMP knows about Redis. Check if this localhost phpinfo page contains “redis”. => If not, follow the following steps to make Redis work with MAMP.

  1. We must install a connection between PHP and Redis:

We search for the possible installations. Pick the one you need for your php version.

brew search redis

It can be that you first need to execute brew tap homebrew/dupes, more info about homebrew/dupes

We want to use it in php 5.6 so we install the following:

brew install homebrew/php/php56-redis

Will give as result a path /usr/local/Cellar/php56-redis/2.2.8, which can vary depending on another version

  1. Open MAMP Pro and click on “File” > “Edit Template” > “PHP” > “PHP 5.6.10 php.ini” (or the version you are using). Go to the part where “extension=” is being defined and add the following:

Restart MAMP and the error will be gone and Redis can be used when starting it up redis-server.

Installation problems

Older alternative way

When using MAMP

Using your own php version instead of

Adding Memcache and Redis to MAMP 2.1.3 (PHP 5.3.20)

Not sure how long this will be good for, but here’s an easy path to adding Memached and Redis support to MAMP 2.1.3. It depends on the fact that, right now, the Homebrew PHP project and MAMP are using the same versions of PHP. This assumes you have Homebrew and MAMP 2.1.3 installed. I’ll just be describing the process for PHP 5.3.20.

  1. Make sure you’ve tapped homebrew-dupes and homebrew-php with: brew tap homebrew/dupes and brew tap josegonzalez/php.

  2. Install memcached and redis for PHP Homebrew: brew install php53-memcache and brew install php53-redis.

  3. Go into MAMP and navigate to: File menu > Edit Template > PHP > PHP php.ini.

  4. Find the “; Extensions” block at line 531. Add the following at the end of the list of current extensions:

    # Use the right folders from brew install

Restart MAMP.

Your PHPInfo should now mention Memcache and Redis.