geerlingguy / drupal-vm

A VM for Drupal development
https://www.drupalvm.com/
MIT License
1.37k stars 645 forks source link

How to use Redis? #287

Closed jiv-e closed 9 years ago

jiv-e commented 9 years ago

What would be the steps to get Redis working on drupal-vm? I have added these:

playbook.yml

# Conditionally-installed roles.
  - { role: geerlingguy.redis, when: '"redis" in installed_extras' }

config.yml

installed_extras:
  - redis

settings.php

$conf['cache_prefix']['default'] = 'myprefix_';
$conf['redis_client_interface'] = 'PhpRedis'; // Can be "Predis".
$conf['redis_client_host'] = '127.0.0.1'; // Your Redis instance hostname.
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_default_class'] = 'Redis_Cache';

The result is an error:

Fatal error: Class 'Redis' not found in /var/www/project/sites/all/modules/contrib/redis/lib/Redis/Client/PhpRedis.php on line 9

Is suppose I need to install PhpRedis. Is there any recommended role to use?

geerlingguy commented 9 years ago

You're 99.9% of the way there; the last part is just adding php5-redis to the set of php_packages in config.yml

For a complete example of setting up Redis with Drupal/PHP via Ansible for Drupal VM (the example is actually from the Raspberry Pi Dramble project!), see this commit:

https://github.com/geerlingguy/raspberry-pi-dramble/commit/d74afc4a433478747dfe778fd5bd1dd752dce325

Would you like Redis to be added as a top-level optional install (just like memcached)? If so, could you add a separate issue in the queue titled "Add Redis as optional install".

Thanks!

jiv-e commented 9 years ago

Great, thanks!

geerlingguy commented 8 years ago

A note for posterity; Redis is officially supported in Drupal VM as of Dec 12 2015!