This is how to install something in a VM and export it as a Vagrant box and use it locally.
First copy the Vagrantfile from below and change the box to the box you want as a base.
Run vagrant up
to create the Virtual Machine and vagrant ssh
to login.
On Windows you might have to put ssh.exe to your %PATH%. If you have installed git, you can use C:\Program Files\Git\usr\bin
You can also login via Putty on host: "localhost", Port "2222", login: "vagrant", password: "vagrant".