Using Vagrant for a Dynamic WordPress Site Development

Vagrant.

Vagrant is a robust open-source software that provides a framework and configuration environment for managing and creating a sustainable WordPress platform. In the past, developers had to rely on local development tools such as MAMP, WAMP or XAMP, giving nightmares to them when it comes to work in a team or switching from one device to the other. But the advances made in WordPress have now introduced more sophisticated tools like Vagrant, providing a myriad of ways for developers to build their own virtual development environment.

Why You Need a Tool Like Vagrant?

Vagrant provides an easy to use work flow and focus on automation, which consequently improves productivity and sayings like “it works on my machine”, just a thing of past.

Developers can easily create their own development environment, anywhere, irrespective of the operating system or platform they choose to accomplish the development task. Plus, they are not restricted to any local machine or Virtual box, instead they can take the advantages of DigitalOcean’s SSD cloud servers, Snapshots and more.

And the best thing about Vagrant is – it’s absolutely portable, means, other members of your team will can also create their own dedicated development environment from the same configuration you use. It makes sure that all the team members working on a project run the same code, dependencies, and configuration, no matter what operating system they are using- Linux, Windows, MAC OS etc.

Vagrant is dynamic. Developers are free to use either their own developed configurations or use the one that are already existing. There is a pool of rich tools and scripts, allow you effectively manage your Vagrant configurations.

How to Get Started with Vagrant?

How to set Vagrant Development System.

To get started, first we need to install two programs – Virtual Box and Vagrant with the help of Vagrant Plugin. VirtualBox is a general-purpose full virtualizer for x86 hardware, targeted at server, desktop and embedded use.

Step 1- Installing Virtual Box

Download and install the latest version of Virtual Box. Also download the latest version of your operating system.

Oracle VM VirtualBox.

Step 2- Installing Vagrant

Now, download the latest version of Vagrant for your operating system. After this, you need to install Vagrant Host Updater Plugin. The plugin is useful for performing modifications on host files, so that VM can be easily incorporated into your terminal.

$vagrant plugin install vagrant-hostsupdater

Step 3- Install Plugin

There is a Vagrant plugin that you can use to manage your hosting files effectively. The plugin is called Vagrant-hostsupdator. The plugin is a quick and easy way of updating your host files as soon as you click on Vagrant up, reload, and resume.

The plugin, after scanning the IP address of the virtual machine, will modify the files accordingly.

Step 4- Configuring Your Own Vagrant File

The moment Vagrant starts with the process of installation, it initially looks like vagrantfile. The file includes all the configuration details. Some of the values included by the file is:

RAM is the first value depicted by the vagrantfile. By default it comes with a storage space of 512MB, but if you want to expand it, simply increase the value just like this:

v.customize ["modifyvm", :id, "--memory", 512]

Another important value that you need to configure is the IP address of the virtual machine. You can change the default IP address in cases when networking issues crop up. The process can be done like this:

config.vm.network :private_network, ip: "192.168.22.8"

The last but not the least, is the configuration folder. In this section, you’ll find two folders- Config on the host area and /srv/config on virtual machine.

config.vm.synced_folder "config/", "/srv/config"

In the same folder, you will also find various configurations for WordPress, PHP, MySQL and more. Once you are done with the process of updating Vagrant file, next you need to provision the configured file into vagrant provision. After this, all the changes will be saved automatically.

Wrapping Up

As you see, now you have created your own local version of WordPress with Vagrant. Now, you have the facility to edit the files locally and transferred simultaneously to your virtual machine with the help of shared folders. When you are done with your work, turn off your virtual machine by simply typing $vagrant halt and it can be enabled with typing $vagrant up. For completely terminating it, run vagrant destroy.

Your Turn to Talk

What’s your Opinion about Vagrant? If you have anything to say, please share your opinion in the comments section. Your opinion matters, unless it is a Spam.

»» This post is co-authored by Boutros AbiChedid. ««

If you enjoyed this post, please consider: linking back to it, subscribing by email to future posts, or subscribing to the RSS feed to have new articles delivered to your feed reader. Thanks!

About the Author |
Ben Wilson has around more than half decade of experience in WordPress associated services. He is working with one of the best HTML to Wordpress conversion company – Wordprax Ltd.. He loves sharing quantum knowledge and acumen about WordPress.
Visit Ben Wilson Website.

Comments are closed.