Note: I’ll be giving a couple of talks about getting started with Vagrant over the next couple months and I intend for this to be a decent description covering some of the basics those who are attending should complete. If are planning on attending in PDX or Seattle, please read this through and complete the steps as best you can.
I wrote an initial blog post a couple months ago that highlights my fascination with Vagrant and may help give a broad overview of the problem I was trying to solve. Keep in mind that I went from eager excitement to mind blown user of Vagrant within 24 hours. This will be you.
Now, ignore everything there and start from scratch.
VirtualBox
VirtualBox is an open source (GPL) cross-platform (that’s everyone!) virtualization application. Oracle provides a great overview in its first steps documentation here – https://www.virtualbox.org/manual/ch01.html
- Download the latest version of VirtualBox (4.2.6) for your operating system and install it on your computer. https://www.virtualbox.org/wiki/Downloads
- Download the matching VirtualBox Extension Pack (4.2.6), the same for all platforms, and install it on your computer. Having VirtualBox installed should make this a recognized file type. https://www.virtualbox.org/wiki/Downloads
Vagrant
Vagrant is an open source (MIT) tool that allows you to setup one or multiple development environments on your local machine that are sandboxed away from your operating system. The getting started guid describes it best:
“Vagrant uses Oracle’s VirtualBox to build configurable, lightweight, and portable virtual machines dynamically.”
I’ll go into much more detail during the presentation, but this is a good start.
- Download the latest stable version of Vagrant (1.0.6) for your operating system and install it on your computer. http://downloads.vagrantup.com/tags/v1.0.6
- Read the overview page of the getting started documentation for Vagrant. If it doesn’t make sense, don’t worry. A familiarity with the terminology will be helpful. Bonus points for every page past the overview section you read. It will all be helpful the second time around. http://docs.vagrantup.com/v1/docs/getting-started/index.html
- Additional reading is available under the general documentation section. http://docs.vagrantup.com/v1/docs/index.html
Create a project.
Vagrant is best explained when you are already up and running with it. To best be prepared for the meetup, it would be great if everyone had the following completed.
- Somewhere on your computer, decide where you want a local environment to live and navigate to that directory. For sanity, I’m going to use ‘pdxwp-vagrant‘ as the environment directory and ‘development‘ as the directory it will live in on your computer.
- Navigate to the containing directory via ‘cd development‘
- Clone the varying vagrant vagrants repository with ‘git clone https://github.com/10up/varying-vagrant-vagrants pdxwp-vagrant`. This will create a directory called ‘pdxwp-vagrant‘ in your ‘development‘ directory that contains all of the files we will need to start up vagrant.
- If you don’t have git available to you by the command line, you can extract the repository’s zip file into a ‘pdxwp-vagrant‘ directory instead.
- Change into the ‘pdxwp-vagrant‘ directory and type ‘vagrant up‘
- A series of messages will appear indicating that Vagrant is downloading a ~600MB box that will act as the base of the virtual machine that we are building. This box started with a specially packed version of Ubuntu 12.0.4 made available directly from Vagrant’s servers. I then installed nginx, mysql, php-fpm and memcached before repackaging it for distribution. This allows us to skip a lot of the provisioning.
- Boxes are cached in your user’s home directory under ‘~/.vagrant.d/boxes`. As long as nothing changes with the ‘config.vm.box‘ or ‘config.vm.box_url‘ parameters in your ‘Vagrantfile‘, the box should stay cached on your system until it is deleted so that you do not have to download 600MB every time you start the server.
- Once ‘vagrant up‘ has finished, you’re ready to go. By default the IP address of the box is ‘192.168.50.4‘. Add an entry for this IP address to your hosts file that points to ‘local.wordpress.dev‘. This will give you access to a default WordPress install right off the bat.
And you’re ready! At this point, don’t worry about screwing anything up. As long as you have VirtualBox and Vagrant installed and the 600MB box cached to your machine, interacting with the box during the meetup will be a breeze.
See you soon!
Responses and reactions
Mentions
Replies
[…] Jeremy Felt gave a talk at the Portland WordPress Meetup and revealed his recently created tool Varying Vagrant Vagrants, which was basically a sophisticated Vagrantfile that spun up an Ubuntu 12.04 VM in VirtualBox and […]
This mostly worked great! Thank you for sharing the info.
The one I sure i am having is with getting wordpress to show correctly.
When I get wordpress to load i get"Warning! Domain mapping upgrade for this domain not found.
Please log in and go to the Domains Upgrades page of your blog to use this domain. " the usernames and passwords on the git page were incorrect for wordpress, phpadmin and mysql.
[...] A WordPress Meetup Introduction to Vagrant – Already slightly out of date, I provided these instructions when speaking at the Portland and Seattle developer meetups. [...]
Jeremy,
Thank you, it seemed to work for me. One glitch--I read the Vagrant instructions as you said, but (without thinking) followed their initial install instructions on the first page. Then--I switched back to your instructions. Mayhem ensued. So, I deleted the first box, then followed *only your install instructions*. No mayhem.
-james
Hi Jeremy!
I'm looking forward to your presentation. I've been wanting to try Vagrant for a while now and here's my chance.
Question: I installed the precise32.box as per your directions. I'm familiar with this version of Ubuntu since it's the same as what I'm running on my file server. Out of curiosity I SSHed into into it and (as sudo) ran apt-get update. There were a whole slew of upates available so I went ahead and did the update. I don't know what the security risks are running in a VM, but I figured I'd better be safe than sorry. Now on to my question, is my having done this going to interfere with my ability to follow along with your presentation? If the underlying OS is out of sync with what you're using, will that change anything on the Vagrant side of things?
Thanks!
Robert
Hey Robert!
This is actually fantastic. I can't see it causing any issues at all and is a great first step when dealing with a new box. In fact, I should probably make that part of the default provisioning.
I would say keep playing around with it until Monday and it will fit in with the presentation and discussion just fine. And if something breaks, a quick vagrant destroy and vagrant up will have you back to the base in minutes.
Thanks!
I'm using a MacBook Pro and already run Parallels for virtual machines, so why would I want to try Vagrant or VirtualBox?
Hey Daniel,
That's a great question. I'm not a user of Parallels and am only somewhat familiar, so I can't answer to what it takes (or if it is possible) to easily provision multiple development environments.
I do know that Vagrant will be supporting at least VMWare Fusion in addition to VirtualBox soon, so my bet is that there will be a day when you can use it with Parallels if you do find it appealing.
As for why it's more or less useful, that will be up to you after the presentation.
The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.
Learn more about Webmentions.