Installing a Drupal site from configuration is useful when running tests or if you don't have a copy of the database. You'll get a copy of the Drupal site without any content that will act in the same way as the live site. You can use modules like default content to add content into the mix so your newly installed site acts a little bit more like the live version.
Since there are some prerequisites to get this up and running I thought I would run through what is needed to get this working and how to run it.
Install Profile Compatibility
Firstly, there is a small issue regarding the hook_install() hook on install profiles that means you'll need to use an install profile that doesn't contain one. The reason for this is that when you have completed your install, importing the config and the needed modules, the install hook will trigger and potentially change the config that you've just installed. To limit the complexity and scope of the change it was decided to simply reject the ability of profiles containing hook_install() hooks from being used.
If you have installed your site using the standard profile (which is probably the case) then you'll see an error like this.
Configuration install: standard
The selected profile has a hook_install() implementation and therefore can not be installed from configuration.
To swap your site to use the minimal profile Use the minimal install profile or any other install profile without a hook_install() hook. To do this in your config you just need to open up the core.extension.yml file and change the profile setting AND the profile name in the list of installed modules. Even though it's not a module it will still appear there so you need to change both instances.
You need to change the core.extension.yml file from this:
Swapping out 'standard' for 'minimal'.
By the way, it looks like this requirement will be removed from future versions of Drupal (probably from 9.1.0 onwards). See this issue on Drupal.org for more information on this.
If you already have config exported you can probably skip this step.
Ensure that your config_sync_directory setting is set in your site settings.php file. This is required by Drupal to know where your config will live.
$settings['config_sync_directory'] = '../config/sync';
With that in place, and the directory created, export your config using drush.
This will place your Drupal configuration into the directory located at ../config/sync.
Running The Install
You can now install the site entirely from fresh using the site:install drush command, along with the --existing-config flag.
drush site:install --existing-config
This will drop all the tables in your database and re-install your site using your previously exported configuration.
Here is some example output from the command running.
$ drush site:install --existing-config
You are about to:
* DROP all tables in your 'drupal' database.
Do you want to continue? (yes/no) [yes]:
[notice] Starting Drupal installation. This takes a while.
[notice] Performed install task: install_select_language
[notice] Performed install task: install_select_profile
[notice] Performed install task: install_load_profile
[notice] Performed install task: install_verify_requirements
[notice] Performed install task: install_write_profile
[notice] Performed install task: install_verify_database_ready
[notice] Performed install task: install_base_system
[notice] Performed install task: install_bootstrap_full
[notice] Performed install task: install_config_import_batch
[notice] Performed install task: install_config_download_translations
[notice] Performed install task: install_config_revert_install_changes
[notice] Performed install task: install_configure_form
[notice] Cron run completed.
[notice] Performed install task: install_finished
[success] Installation complete. User name: admin User password: ....
If you want to see the original change record for installing Drupal from an existing configuration.