WordPress + Vagrant + Chef = Magic

awsWordPress

My name is Michael Bastos and I’m a Polyglot Software Engineer out of San Diego and I help run the Advanced WordPress Group (AWP) on Facebook at over 1300+ members, a Google Plus at over 70+ members and Meetup.com at over 120+ members.

My day job is writing software for the military while I work on my own startup in my free time, but I’ve been involved with the WordPress community since 2009 and am still in love with the people and the friends I’ve made along the way so I’ve wanted to help push the development envelope for WP thus why I created AWP almost two years ago.

Recently I had the pleasure of releasing my open source Chef deployment tool for WordPress called WP-Chef. For those who aren’t familiar with Chef, it’s essentially a DevOps or automated deployment framework built in Ruby that consists of a number of scripts called Recipes that allow you to very quickly and efficiently build an entire server installation in a matter of minutes. I’ve included detailed instructions on how to install Vagrant and use WP-Chef as it stands so far.

As a long time Linux Only Developer I’ve always had a habit of building automated Bash scripts to prevent me from having to do repetitive work (A vestige of my Perl development days). A few years ago as my personal client base began to grow I started moving away from hosted and VPS solutions and decided to do everything in the cloud, in this case I now work almost exclusively with Amazon Web Services (AWS) but still do some work on RackSpace Cloud from time to time.

When I made the full transition I realized that I needed to speed up my server automation process so I started researching DevOps frameworks like Chef and Capistrano and decided on Chef because of my heavy Ruby background. I’ve done talks at WordCamp NYC as well as WordCamp Las Vegas on getting familiar with AWS but never had the time to release any of my personal Chef Scripts until now.

Please keep in mind that WP-Chef is still Beta software, migrating scripts that I built for personalized use and getting it to work on a variety of systems takes time and I’ve integrated Vagrant to handle both the deployment of local builds as well as remotely building a server on Amazon. I’ve also started adding code for RackSpace deployment and will role that out soon.

So what works? Well right now if you clone the WP-Chef code base you’ll have the option between setting up an Apache or Nginx configuration, the Apache option works great and can be used to test deploy right now if you wish. The Nginx configuration is still a work in progress, I have Nginx, PHP-FPM/APC and MySQL installing and running perfectly in the script, the only thing that’s missing at this point is the WordPress installation and setup itself. Once the Nginx option is done I’ll start working on a combination configuration that allows you to run Nginx on port 80 and Apache on port 8080, for those of you who run servers, you’ll understand how valuable this is for implementing .htaccess rules with Nginx.

The real secret sauce will be the final piece of WP-Chef, remote S3 and RDS deployments, this is the version that I’m excited to release but I have to get a stable Nginx and combination version working first. The distributed deployment will allow you to assign a remote database service like RDS and a remote upload service like S3 allowing you to deploy multiple servers for the same website and a single private git repository, in terms of being able to scale up or down a single site, you can understand the benefits of creating an unlimited number of servers within minutes for a single installation of WordPress.

Why am I writing this article then? Other projects exist like WP-Stack which uses Capistrano and I want to see more of these kind of ease of deployment tools. My hope is that other people out there are as interested in the success of WP-Chef as I am and would be willing to jump in and help, this is all open source software anyhow and my personal Start-up has nothing to do with WordPress so I see this project as more giving back to a community that’s given me so much already. The more people I can have looking at the code or just testing the deployments and telling me where the bugs are the better the software gets. If all of this seems exciting to you then message me on twitter @bastosmichael or you can follow me on github. In the end when you combine WordPress, Vagrant and Chef, professionally deploying your websites really does start to feel like magic…

Comments

  1. By on

    This is awesome Michael, thanks for sharing it. I do find it funny that to find this a second time I just google’d “Bastos Vagrant Chef”.

    One thing I wonder is why the reliance on Ruby for these DevOps instead of Node or better PHP. Don’t get me wrong, I need to learn a little Ruby and I assume there is a reason for it, just wondering what it is.

    • By on

      Thanks for the comment, Chef on it’s own is a Ruby based DevOps frameworks which is also the industry standard for OpsWorks so my choice on using it had more to do with the fact that it’s the standard for most DevOps implementations and Ruby is the language I work in more than PHP these days so I’m well versed and familiar with it. There are other tools that do stuff like this including VVV from @10up which also uses Vagrant but is based more on Shell Scripting so it’s really a choice of implementation and setup. Not sure if there’s a PHP DevOps framework but I’d love to hear about it if one exists. My goal is to have the Nginx Cookbook done by the end of the month if time permits but you can try out the Apache Cookbook and it works just fine…

      PS – Vagrant is itself a Ruby Gem so it’s also written in Ruby and having Ruby On Ruby vs Bash or Shell scripting on Ruby is more preferable in my opinion…

Trackbacks