Setting up Drupal 8 with DrupalVM on my Mac

selwyn's picture

This allows me to setup a fresh Drupal 8 site with DrupalVM ver 4.7

Note. I was able to make DrupalVM version 4.8 work but I had a few minor issues such as permissions in the sites/default/files directory and the fact that it uses drush 9

See Jeff Geerlings blog post for more info

Download drupalvm version 4.7.2

unzip and copy it to a folder in ~/Sites  eg ~/Sites/dev1

Edit config.yml to make the following changes

1. hostname/ip etc.
vagrant_hostname: dev1
vagrant_machine_name: dev1

2. Vagrant synced folders:
set local_path and destination

  - local_path: .
    destination: /var/www/dev1

3. set the drupal_composer_install_dir:
drupal_composer_install_dir: "/var/www/dev1"

4. Drupal Install site:
set this true so drupal installs the site to begin with, then set it back to false after installing to avoid drupalvm overwriting your db
drupal_install_site: true <---after it's running change to false!

5. Required Drupal Settings:
# Required Drupal settings.
drupal_core_path: "{{ drupal_composer_install_dir }}/web"

6. Which modules you want added to the site:
drupal_enable_modules: [ 'devel', 'admin_toolbar' ]

Also add them under drupal_composer_dependencies. In the example below admin_toolbar is added at ver 1.21 or higher.

  - "drupal/devel:1.x-dev"
  - "drupal/admin_toolbar:~1.21"


7. for SSL add this under the apache_vhosts section:

  - servername: "{{ drupal_domain }}"
    documentroot: "{{ drupal_core_path }}"
    certificate_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem"
    certificate_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key"
    extra_parameters: |
          ProxyPassMatch ^/(.*\.php(/.*)?)$ "fcgi://{{ drupal_core_path }}"

8. Installed extras:

Here is my list for a simple Drupal 8 site.

  - adminer
  # - blackfire
  - drupalconsole
  - drush
  # - elasticsearch
  # - java
  - mailhog
  - memcached
  # - newrelic
  # - nodejs
  - pimpmylog
  # - redis
  # - ruby
  # - selenium
  # - solr
  # - tideways
  - upload-progress
  - varnish
  # - xdebug
  # - xhprof # use `tideways` if you're installing PHP 7+

9. PHP Configuration.

php_version: "7.1"
php_install_recommends: no
php_memory_limit: "512M"

10. MySQL Config
You can add these items below to get better mysql performance:

#MySQL Optimizations (Selwyn 10-16-2017)
mysql_key_buffer_size: 512M
mysql_max_allowed_packet: 1073741824
mysql_table_open_cache: 512
mysql_sort_buffer_size: 2M
mysql_read_buffer_size: 2M
mysql_read_rnd_buffer_size: 8M
mysql_myisam_sort_buffer_size: 2M
mysql_thread_cache_size: 8
mysql_query_cache_size: 128M
mysql_query_cache_limit: 1M
mysql_max_connections: 151
mysql_tmp_table_size: 16M
mysql_max_heap_table_size: 16M
mysql_group_concat_max_len: 1024
mysql_join_buffer_size: 262144
mysql_innodb_file_per_table: 1
mysql_innodb_buffer_pool_size: 512M
mysql_innodb_log_file_size: 256M


11. vagrant up

When this completes, your Drupal 8 site will exist with a user 1 with a name/password of admin/admin. You will also have a web/sites/default/settings.php all configured and ready to go.  In this case, navigate to https://dev1 and you should see the familiar Drupal 8 site.

12. If the site fails to load it's css files, you may have to set perms for web/sites/default/files 
$ vagrant ssh
$ cd sites/default
$ sudo chmod -R 777 files
$ drush cr
<Ctrl> d

13. This would be a good time to load your db if you have one

Drush does setup the drush aliases so you can use them (e.g. drush @dev1 sql-dump) or use vagrant ssh

Here is how you dump the db locally:
drush sql-dump >dbdump1.sql

And here is how you load your dump file into mysql
drush sqlc<dbdump1.sql


Once Drupal 8 is running, use this process to add modules:
vagrant ssh
composer require drupal/honeypot
drush en honeypot


composer require drupal/admin_toolbar
drush en admin_toolbar admin_toolbar_tools

(You need to vagrant ssh so composer will use php7.1.  You could rather install it locally instead)

For specific versions of modules use:
composer require drupal/migrate_plus:~4.0
which will install migrate_plus 8.x-4.0-beta2

either use drush or modules u/i to enable

To update a drupal module e.g. config_update:
composer require drupal/config_update

I've made a gist of the entire config.yml file which you can see at the end of this article.

More docs at