Configuration Management Through the UI and with Drush
If you've been working with Drupal 7 for any length of time, you'll have heard of a module called Features. Features was originally developed to bundle a specific set of functionality (like a content type, image styles and view that are all used to create an image gallery). The idea being that that set of functionality could be re-used across projects. After a while people started to use it to export configuration to code so that it could be moved to different instances of the same site (ie: development, staging and production). This wasn't really what Features was designed to do, so there were a number of hacks and workarounds that some had to use in order to make it work that way.
Drupal 8 introduced a new configuration system called Configuration Management which is designed specifically to facilitate moving configuration between instances of the same site (ie: development, staging and production). Features still exists to bundle functionality that's intended to be used on different sites, but Configuration Management is the recommended way to handle moving configuration between different instances of the same site.
Setting the Config Directory in settings.php
Drupal will store configuration files in the directory specified in settings.php. Let's take a look at where that is.
- Open settings.php
If we take a look at the "$config_directories" line, you'll see that it's set to store the config files in "sites/default/files/config_(randomhash)/sync". By default, Drupal will create a directory like this for each site. The downside is that the "sites/default/files" directory is web-accessible. The hash is generated to make finding these files very difficult, and Drupal creates a .htaccess file that should restrict access to your configuration files, but if you really want to tighten up security these should be placed outside the web root.
Luckily, that's super easy with our current setup. All we need to do is set the directory to something like "../config/sync". This has the added benefit of placing the files in our Git repo (the default "sites/default/files" directory shouldn't be in your repo) so that we can easily sync between environments and keep our configuration version controlled, while keeping it one level above our web directory so that they are not web accessible.
I'll change that configuration to look like this:
* Configuration sync directory
$config_directories['sync'] = '../config/sync';
With that done, I'll go ahead the just delete the old config directory.
rm -rf sites/default/files/config_(randomhash)/
I also want to mention that this is something that should be in settings.php and not settings.local.php so that all of the sites know where to look for the config files.