How to Use Vagrant in WordPress Development

You are here : Home / How to Use Vagrant in WordPress Development

Vagrant for wordpress development comes in mind when you think about your difficulties to share same development environment between developers. Sometime few things works on your pc but not on your client’s pc or on live server. To rectify such issues, we need same server environment to see what exactly happening on other side.

At FlipperCode, by using vagrant, we improved our development speed and accuracy. This article is about why we adopted vagrant, what are the results and how you can achieve the same.

Why Vagrant for WordPress Development?

Vagrant helps you to make your wordpress development cycle easy dramatically. Below are the reasons we prefer Vagrant for our every wordpress project.

  • Mismatch Server Configurations: Server configuration is most of time different than our local environment which cause conflict issues and hardly to resolve.
  • Difficult Sharing: There’re too many steps to configure everything locally to match with team mate. isn’t?
  • Repeatable Steps: Copy wordpress core folder, create a new database using phpmyadmin, setup wp-config.php and so on.. are repeatable steps we need to do to start a wordpress project. It’s boring.

Benefits of Vagrant in WordPress Development

Profit is backbones of every business and vagrant helps us to speed up development, more projects in a month and more profit. Below are the advantages of vagrant we get everyday.

  • No excuse anymore: “Works on my PC”, “Your server is not compatible”, “It’s not happening for me” and many more, excuse happening in IT. Vagrant setup an exactly same development environment for everyone and easy to switch between environments.
  • Development time: “vagrant up”, a command can setup everything for you and you just start write down your coding.
  • Easy Collaboration: You need not to share hundred of files anymore, just a configuration file and “vagrant up –provision” take care rest for you.
  • Command line Interface: Vagrant reduced our mouse clicks. Less switching between editor and browser because of command line interface for wordpress development.

Setup your First Project using Vagrant

Ready for your first wordpress project using vagrant? Let’s do it in steps. Assume that you just purchased a new laptop. No any Software/tools installed on your system. Hope it’s ideal situation to get started with something new :).

  • Step 1: Install Virtual Box which is required for vagrant to switch between server environments.
  • Step 2: Install Vagrant in few easy steps. At the end, make sure “vagrant” command is available in your terminal.
  • Step 3: Its best practice to use provisioned domains (first_project.dev or first_project.com) instead of “http://localhost/first_project” ugly root url. For that, Install the vagrant-hostsupdater plugin with
  • Step 4: Up to now, your system only have vagrant and virtual box. No XAMPP/LAMPP. Now download this Varying Vagrant Vagrants project and extract it anywhere you wish to put your projects. We’re Assuming VVV folder for rest of article. You should see a folder structure as below.vvv folder How to Use Vagrant in WordPress Development
  • Step 5: You might be wonder how it works without XAMPP/LAMPP which was essential part of your development life. Now open terminal and navigate to VVV folder and run “vagrant up”.

    This could take a while to run first time because it download required files. Once installation complete, you get all tools required for a development listed here
  • Step 6: Up to now, you have everything what you need and need not these steps again in future. for your first wordpress project, create a new folder “first_project” in “www” folder.Selection 012 How to Use Vagrant in WordPress Development
  • Step 7: Create a file vvv-init.sh and paste following code in it.
  • Step 8: Create a second file vvv-hosts and paste following content in it.
  • Step 9: Now create a third and last file vvv-nginx.conf and paste below code in it.
  • Step 10: So you first_project should have following structure.first project structure How to Use Vagrant in WordPress Development
  • Step 11: up to now you have setup your project configurations and now run “vagrant up”. In few minutes, It’ll keep ready your new development project and browse http://first_project.dev on your browser.

Conclusion

It took a complete day to me when i tried vagrant first time and setup these steps but now It takes only a minute to setup a new wordpress project and start my coding. e.g you wish to distribute this project to your team, just copy these 3 files and send to them. If you want to create a second project, just copy these 3 files in a folder and change your settings. At the end run “vagrant up”. Hopefully this article is worth in your wordpress development.

 How to Use Vagrant in WordPress Development

Flipper Code

We have been building WordPress Plugins at flipper code since 2008. We follow wordpress coding standard that ensures we deliver the excellent wordpress plugins and services.

More Posts - Website

Follow Me:
twitter How to Use Vagrant in WordPress Developmentfacebook How to Use Vagrant in WordPress Developmentgoogleplus How to Use Vagrant in WordPress Development

Customize Product according to your requirements?

We will be glad to discuss any of your needs related to our wordpress plugins . if any of functionality you'd like to see in products, you can reach us by via email hello@flippercode.com.