WordPress Development Workflow: Installing Varying Vagrant Vagrants on Ubuntu

This post is to sum up my 50 hours long struggle which led me to do two reinstalls of Ubuntu, just to install Vagrant and then Varying Vagrant Vagrants for the WordPress Development Workflow.

Now, let me make this clear, so that you don’t have to browse through several tuts to read something specific on Ubuntu + Vagrant +VVV combo – there is no need to do so. That being said, yes you will face issues if you, like me, have screwed up directory permissions, don’t know what’s been done with git cloning permissions and so forth.

I did the below mentioned steps on the Ubuntu 16.04 (Xenial Xerus) which was freshly installed for the purpose.

First, I went into ‘Software and Updates’ and ticked-on all the options that installs softwares from different sources. Post that, I set the server to ‘Main Server’. This was done because as you will see in the below steps, we need to install two softwares via debian packages and that throws an error if the aforementioned is not done.

Second, I run ‘Software Updater’ and install all the updates as from the aforementioned step, the system now has many updates for you to install. Once that is done, reboot the system.

Third, download VirtualBox. Based on my OS, I downloaded Xenial i386 version but you need to lookout for your specific version.

Fourth, download Vagrant . Again, here I went for Debian 32-bit version.

Now, follow the steps below:

  1. Install git, if you havent already by sudo apt-get install git  in your terminal.
  2. Right click on the VirtualBox (downloaded package) and open in the Software Center. Install it.
  3. Right click on the Vagrant (downloaded package) and open in the Software Center. Install it.
  4. In your terminal, run vagrant plugin install vagrant-hostsupdater
  5. Once that is done, run vagrant plugin install vagrant-triggers
  6. Now, clone the VVV got repo in a new folder (inside your home directory) by running git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git vagrant
    • If this fails use the same command by prefixing sudo  to it.
  7. In your terminal, go inside that folder by cd vagrant
  8. Now, run vagrant up
    • This will search for an existing VagrantFile and obviously it won’t find it. Hence, it will make one and will setup your Ubuntu/trusty64 server. If this happens, pat your back and take some rest as this step will take a while.
    • If this fails, run vagrant init  and then run vagrant up
  9. If all is merry till now, clone a site wizard for VVV created by BradP by git clone https://github.com/bradp/vv.git
  10. Then clone Leo Gopal’s git repo which acts as dashboard for VVV by git clone https://github.com/leogopal/VVV-Dashboard.git
  11. If all is fair till now, run mv VVV-Dashboard/dashboard* www/default/
  12. Now, do a cool dance move and check vv.dev on your browser.
  13. One last step, do cd /  . This will bring you out of ‘vagrant’ directory. Now, run sudo cp /home/<your username directory>/vagrant/vv/vv /usr/local/bin
    • This will copy the executable script of vv which will help you in creating new websites via running vv create
    • If you face issue, like getting 404 on your new website after vv create  function, do the following:
      • cd dev/vagrant-local  # Use location of vagrant-local on your machine
      • vagrant ssh
      • cd /srv/www/Your-Site-Name
      • ./vvv-init.sh

Now, in a nutshell what we did here is – We installed Vagrant which is a super cool tool, used by all the cool kids, for the local development workflow. What is does is, it takes help from the VirtualBox and creates virtual server on your local machine for you to do local development on.

In our case in step 8, it setup Ubuntu/trusty64. The advantage of Vagrant is that it gives you exact feel and replica of a server running on the specific OS rather than emulating the behaviour like MAMP, XAMP or WAMP does.

VVV (Varying Vagrants Vagrant) is created by 10up and is Vagrant configuration for WordPress developers. The environment is flexible, easy to edit and focused on high traffic, production environments. By using VVV, you get production ready configurations to work with on your own systems, right away. I copied all this shamelessly from Sitepoint’s piece on VVV. Go have a look yourself for VVV’s merits.

Now, time for some resources.

There are few commands you should know. I copied below mentioned from WebDevStudios:

vagrant up  – When in the VVV root directory, this will start the virtual machine that powers VVV. It will set up your hosts file with the correct local domain names, update your local versions of WordPress, and run any custom init scripts you have set up. (More on this later!)

vagrant halt  – This pauses Vagrant. This is useful when you’re on battery power, aren’t using VVV, and you don’t want to run a virtual machine in the background.

vagrant provision  – This runs provisioning scripts. These are the things that VVV uses to make sure it is set up correctly. You generally don’t need to do this all the time, but I recommend running this command if you start having issues and want to start troubleshooting.

vagrant ssh  – And this connects you to VVV via ssh. This is probably my favorite command, as it allows you to run commands inside of the virtual machine. I use this mostly to run WP-CLI and PHPUnit things inside of VVV.

Below, post Vagrant and VVV installation, following is the list of some local sites for you to use, again copied from same article by WebDev Studios:

Also, let me tell you – once I’ve sat in this Vagrant + VVV bandwagon, am browsing through lot of links to explore more, am listing them down below for your reference:

So, this ends here. Let me know if this helps you, confuses you or you have something to add.


Leave a Reply

%d bloggers like this: