Virtual Box, Vagrant and VVV

Description

For working remotely, it is beneficial to set up a local server on your own machine at home to allow you to run sites smoothly for testing purposes, or while being away from the office.

  1. Download and install VirtualBox. This will allow virtual machines to be set up on your computer. A virtual machine is used to run the server software.
  2. Download and install Vagrant. This is the software that utilizes VirtualBox to create a functioning server on your machine.
  3. In your command line terminal, run the following command:
    vagrant plugin install vagrant-hostsupdater
  4. Again in the terminal, run this command to clone the VVV repo to your machine. Change [YOUR_DIRECTORY] with the name you would like for your server directory:
    git clone -b master git://github.com/Varying-Vagrant-Vagrants/VVV.git ~/[YOUR_DIRECTORY]
  5. In your file explorer, open that directory and copy the vvv-config.yml file. Rename the duplicate vvv-custom.yml.
  6. In your terminal, cd into your newly created server directory. Run:
    vagrant up
  7. It should take a few minutes to provision the server for the first time. Once that process is complete, the server will be up and running. Be sure to shut it down when you are done using it by running:
    vagrant halt

Adding New Sites

To add a new site to your local server, open up your file explorer, navigate to your server directory and open up the vvv-custom.yml file. Between lines 37 and 41, you will see this code commented out:

#mysite:
# description: “My website”
# repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
# hosts:
# – mysite.com

 

Duplicate this code and uncomment it. Change the necessary information (mysite, mysite.com, the description, the repo, etc.) Save the file.
In your terminal, cd into the server directory. Run the following:
vagrant halt
then:
vagrant up --provision
This will reboot the server and will reload the available sites (which are called in within the vvv-custom.yml file). It should only take a couple of minutes for the server to be up and running again and then you should have access to the newly added URL.
NOTE: The .yml files are very particular about syntax. They will ONLY work if spaces are used, and will throw an error if any tabs are used. Some code editors will automatically replace consecutive spaces with equivalent tabs, which will cause the server to error out.
MENU