Creating a new site in your Drupal VM

May 11, 2017

DrupalVM

The less I have to deal with setting up my local, the better.

I always recommend using the same environment as your back end lead.  They can help you sort out any issues that you might run into. Below are the steps I take to create a new site in my Druplal VM a VagrantAnsible environment.

 

Set up a vm alias

In the terminal nano into the host configuration.

example:

Create a new database

log into virtual machine first

access the mysql shell

review/show all databases

create the database

review/show all databases

Import the database

Move the downloaded db to your database dump file on drupal-vm. Since you’re already in the vm, use autocomplete to find the file.
HINT: Keep an eye on the date if you have multiple database files.

Place your files into the new site folder.

upload files to sites/default/

rename from files_dev to files

update the settings.local.php and adjust the database name

Create a new configuration file for nginx

To do this we are updating sites-enabled to include a new file for your local nginx configuration file

Copy from a working config to sitename.dev.conf

nano into the conf file

Change the server name and root 

Restart nginx server

Be sure to checkout the branch you want to work with if you are still on master

Clear cache

Start up dev site in browser

sitename.dev

 

That’s it. Good luck and God speed!

 

Generic notes for Vagrant

  • To shut down the virtual machine, enter vagrant halt in the Terminal in the same folder that has the Vagrantfile. To destroy it completely (if you want to save a little disk space, or want to rebuild it from scratch with vagrant up again), type in vagrant destroy
  • To log into the virtual machine, enter vagrant ssh. You can also get the machine’s SSH connection details with vagrant ssh-config.
  • When you rebuild the VM (e.g. vagrant destroy and then another vagrant up), make sure you clear out the contents of the drupal folder on your host machine, or Drupal will return some errors when the VM is rebuilt (it won’t reinstall Drupal cleanly).
  • You can change the installed version of Drupal or drush, or any other configuration options, by editing the variables within config.yml.