Drupal settings

Below you will find instructions on configuring your Drupal project to work with Docksal. Some settings are required; others are optional or enhancements. Please review carefully.

DB connection settings (required)

Below are sample settings for Drupal 7 and Drupal8.

Drupal 7 and 8

# Docksal DB connection settings.
$databases['default']['default'] = array (
  'database' => 'default',
  'username' => 'user',
  'password' => 'user',
  'host' => 'db',
  'driver' => 'mysql',
);

File permissions fix (required)

To make sure files and folders generated by Drupal are writable add the following to your settings.php file.

Drupal 7

# Workaround for permission issues with NFS shares in Vagrant
$conf['file_chmod_directory'] = 0777;
$conf['file_chmod_file'] = 0666;

Drupal 8

# Workaround for permission issues with NFS shares in Vagrant
$settings['file_chmod_directory'] = 0777;
$settings['file_chmod_file'] = 0666;

You may also have to reset permissions on the existing files folder. The following command will recursively set folders to 777 (rwx) and files to 666 (rw).

chmod -R +rwX files

Reverse proxy settings (optional)

In some cases you have to let Drupal know if HTTPS is used. Add the following lines to settings.php:

Drupal 7

# Reverse proxy configuration (Docksal's vhost-proxy)
if (!drupal_is_cli()) {
  $conf['reverse_proxy'] = TRUE;
  $conf['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);
  // HTTPS behind reverse-proxy
  if (
    isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' &&
    !empty($conf['reverse_proxy']) && in_array($_SERVER['REMOTE_ADDR'], $conf['reverse_proxy_addresses'])
  ) {
    $_SERVER['HTTPS'] = 'on';
    // This is hardcoded because there is no header specifying the original port.
    $_SERVER['SERVER_PORT'] = 443;
  }
}

Drupal 8

# Reverse proxy configuration (Docksal's vhost-proxy)
if (PHP_SAPI !== 'cli') {
  $settings['reverse_proxy'] = TRUE;
  $settings['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);
  // HTTPS behind reverse-proxy
  if (
    isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' &&
    !empty($settings['reverse_proxy']) && in_array($_SERVER['REMOTE_ADDR'], $settings['reverse_proxy_addresses'])
  ) {
    $_SERVER['HTTPS'] = 'on';
    // This is hardcoded because there is no header specifying the original port.
    $_SERVER['SERVER_PORT'] = 443;
  }
}

Memcache settings (optional)

Follow Memcached instructions.

Use memcached:11211 as the memcached endpoint.

Drupal 7

Edit settings.php and add the following lines to point Drupal to the memcached service.
Replace </path/to/memcache-module> with the path to memcache module in your project, e.g., sites/all/modules/contrib/memcache.

// Memcache module settings
$conf['cache_backends'][] = '</path/to/memcache-module>/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_servers'] = array(
  'memcached:11211' => 'default',
);

Drupal 8

Enable the Memcache module in Drupal.

Configuring memcache in Drupal 8 requires the Memcache module to first be enabled. (Re)installing a Drupal 8 site with these settings will fail. Comment the settings out, (re)install, then uncomment the settings back.

Edit settings.php and add the following lines to point Drupal to the memcached service.

// Memcache module settings
$settings['memcache']['servers'] = ['memcached:11211' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = '';
$settings['cache']['default'] = 'cache.backend.memcache';