Make Vagrant Environments is a Vagrant configuration based on Varying Vagrant Vagrants which is focused on WordPress development.
- Verions: 0.1-working
- Contributors: @colegeissinger, @whyisjake
- Contributing: Contributions are more than welcome. Please submit pull requests against the master branch. Thanks!
The primary goal of MVE is to simplify development at Maker Media and accurately test against WordPress VIP locally. For a while we used MAMP and personally updating our local developments individually, but things are becoming more complicated as the team grows. We have decided to move to using Vagrant, a way to create virtual machines for testing and developing in an enviroment just like our production server.
This forked copy of Varying Vagrant Vagrants is modified to support Maker Media's web dev team by loading an environment for both Mage Magazine and Maker Faire, load both themes and also create a database with standard content. Also, this version is syncing with develop.svn.wordpress.org, which is the new and preferred development area for WordPress.
In a future version, this MVE will install and use Node.js and Grunt as recommended with the new WordPress development build process which incorporates Unit Testing and i18n translations.
Vagrant is a "tool for building and distributing development environments". It works with virtualization software such as VirtualBox to provide a virtual machine that is sandboxed away from your local environment.
- Start with any operating system.
- Install VirtualBox 4.2.16
- MVE (and Vagrant) has been tested with this version. If a newer version appears on the downloads page and you don't feel like being a guinea pig, check out the older downloads page and download the 4.2.16 release.
- Install Vagrant 1.2.5
vagrant
will now be available as a command in the terminal, try it out.
- Clone the Make Vagrant Environments repository into a local directory. At Make, we prefer to work off the "~/Sites" directory in OS X.
git clone git://github.com/colegeissinger/make-vagrant-environments.git
- OR download and extract the repository master zip file
- Change into the new directory
cd ~/Sites
- Start the Vagrant environment
vagrant up
- omg magic happens- Be patient, this could take a while, especially on the first run.
- Add a record to your local machine's hosts file
192.168.50.4 local.make.dev
- On -nix systems you can use: (note that location of host file after the >> may vary)
sudo sh -c 'echo "192.168.50.4 local.make.dev" >> /private/etc/hosts'
- Visit
http://local.make.dev/
in your browser for Makezine.com. By default we load the Make Magazine theme and database.
The first time you run vagrant up
, a pre-packaged virtual machine box is downloaded to your local machine and cached for future use. The file used by Make Vagrant Environments contains an Ubuntu 12.04 installation (Precise release) and is about 280MB.
After this box is downloaded, it begins to boot as a sandboxed virtual machine using VirtualBox. When ready, it runs the provisioning script also provided with this repository. This initiates the download and installation of around 88MB of packages on the new virtual machine.
The time for all of this to happen depends a lot on the speed of your Internet connection. If you are on a fast cable connection, it will more than likely only take several minutes.
On future runs of vagrant up
, the pre-packaged box will already be cached on your machine and Vagrant will only need to deal with provisioning. If the machine has been destroyed with vagrant destroy
, it will need to download the full 88MB of packages to install. If the vagrant has been powered off with vagrant halt
, the provisioning script will run but will not need to download anything.
Now that we have MVE running, let's talk about changing databases. Instead of having multiple copies of WordPress setup, we use one set of core files and multiple databases. MVE includes a shell script that you can use to automate switching databases. You can find this in the root of the repository called switch-make-database.sh
. Move this file into the bin folder in your user directory. Doing this will make this file globally accessable in any directory. In some instances this directory does not exist, go ahead and create it.
To create a bin directory in your user directory, in terminal type in cd ~; mkdir bin
. Now you can move switch-make-database.sh
into that bin folder.
- Open Terminal and type
switch-make-database.sh makeblog
orswitch-make-database.sh makerfaire
Fancy, yeah?
But wait, that's not all!
- Access the server with
vagrant ssh
from your~/Sites
directory. You can do pretty much anything you would do with a standard Ubuntu installation on a full server.- If you are on a Windows PC, you may need to install additional software for this to work seamlessly. A terminal program such as Putty will provide access immediately.
- Destroy the box and start from scratch with
vagrant destroy
- As explained before, the initial 280MB box file will be cached on your machine. the next
vagrant up
command will initiate the complete provisioning process again.
- As explained before, the initial 280MB box file will be cached on your machine. the next
- Power off the box with
vagrant halt
or suspend it withvagrant suspend
. If you suspend it, you can bring it back quickly withvagrant resume
, if you halt it, you can bring it back withvagrant up
. - Other Notes
- The network configuration picks an IP of 192.168.50.4. This works if you are not on the 192.168.50.x sub domain, it could cause conflicts on your existing network if you are on a 192.168.50.x sub domain already. You can configure any IP address in the
Vagrantfile
and it will be used on the nextvagrant up
- If you require any custom SQL commands to run when the virtual machine boots, move
database/init-custom.sql.sample
todatabase/init-custom.sql
and edit it to add whicheverCREATE DATABASE
andGRANT ALL PRIVILEGES
statements you want to run on startup to prepare mysql for SQL imports (see next bullet). - Have any SQL files that should be imported in the
database/backups/
directory and named asdb_name.sql
. Theimport-sql.sh
script will run automatically when the VM is built and import these databases into the new mysql install as long as the proper databases have already been created via the previous step's SQL. - Check out the example nginx configurations in
config/nginx-config/sites
and create any other site specific configs you think should be available on server start. The web directory is/srv/www/
and default configs are provided for basic WordPress 3.5.1 and trunk setups. - Once a database is imported on the initial
vagrant up
, it will persist on the local machine a mapped mysql data directory. - Other stuff. Familiarize and all that.
- The network configuration picks an IP of 192.168.50.4. This works if you are not on the 192.168.50.x sub domain, it could cause conflicts on your existing network if you are on a 192.168.50.x sub domain already. You can configure any IP address in the
- URL:
http://local.make.dev
- DB Name:
makeblog
ormakerfaire
(seeusing switch-make-database.sh
for switching databases) - DB User:
root
- DB Pass:
blank
- Admin User:
admin
- Admin Pass:
admin
MySQL via phpMyAdmin
- URL:
http://local.default.dev/phpmysql
- User:
root
- Pass:
blank
MySQL Locally (Sequal Pro (OS X), HeidiSQL (Windows), or MySQL Workbench (Cross-platform)
- SSH Tunnel
- SSH Host:
local.make.dev
(alternativaly you can input the IP address192.168.50.4
) - SSH User:
vagrant
- SSH Pass:
vagrant
- SSH Port: Leave blank or default
- MySQL Host: 127.0.0.1
- MySQL User:
root
- MySQL Pass:
blank
- Database & Prot: Leave blank or default
A bunch of stuff!
- Ubuntu 12.04 LTS (Precise Pangolin)
- nginx 1.4.2
- mysql 5.5.31
- php-fpm 5.4.17
- memcached 1.4.13
- PHP memcache extension 3.0.6
- xdebug 2.2.1
- PHPUnit 3.7.21
- ack-grep 2.04
- git 1.8.3.4
- subversion 1.7.9
- ngrep
- dos2unix
- WordPress Development trunk
- WP-CLI
- Composer
- phpMemcachedAdmin 1.2.2 BETA
- phpMyAdmin 4.0.3
- Webgrind 1.1