Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamxiaoz/9901423 to your computer and use it in GitHub Desktop.
Save hamxiaoz/9901423 to your computer and use it in GitHub Desktop.

Tutorial: Meteor in Windows using Vagrant

These days some people were discussing at meteor-talk group about running Meteor at Windows and I’ve recommended them using Vagrant. It’s a very developer-friendly piece of software that creates a virtual machine (VM) which let you run any operating system wanted and connect to it without big efforts of configuration (just make the initial installation and you have it working).

Many packages (I've tested) for running Meteor+Vagrant fails because Meteor writes its mongodb file and also other files inside local build folder into a shared folder between the Windows host and the Linux guest, and it simply does not work. So I've put my brain to work and found a solution: do symlinks inside the VM (but do not use ln. Use mount so git can follow it). It’s covered on steps 8 to 15.

If you have no idea what I’m talking about, I’ve made a tutorial to install Ubuntu Precise x86 through Windows command-line with Meteor very simple to follow:

Requirements

#!/bin/bash
sudo apt-get update
sudo apt-get install python-software-properties
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
sudo apt-get update
sudo apt-get install -y git mongodb-10gen curl
cd /usr/local
wget http://nodejs.org/dist/v0.10.11/node-v0.10.11-linux-x86.tar.gz
sudo tar -xvzf node-v0.10.11-linux-x86.tar.gz --strip=1
rm -f node-v0.10.11-linux-x86.tar.gz
curl https://install.meteor.com | sudo sh
sudo npm install -g meteorite

Steps on Windows command-line:

  1. Go to Start Menu > Type cmd > SHIFT + ENTER (to login as Administrator)
  2. cd C:\path\to\your\vagrant+meteor\project\folder
  3. set PATH=%PATH%;C:\Program Files (x86)\Git\bin (Append git binaries to path so vagrant can run ssh)
  4. vagrant init precise32 http://files.vagrantup.com/precise32.box (To install Ubuntu 10.04 x86)
  5. Edit the Vagrantfile with your preferred editor and add those two lines anywhere inside the Vagrant.configure(“2”) block:
config.vm.provision :shell, :path => "meteor.sh"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
  1. vagrant up (It will download box, configure meteor and get it up)
  2. vagrant ssh (It will connect on the VM and expose its command-line). Or you can use PUTTY to ssh into it.
  3. the default user and pw is 'vagrant'
  4. if you see openssh warning, convert the private key using puttygen and run:
ssh vagrant@127.0.0.1 -P 2222 -i the-converted-private-key-file\insecure_private_key.ppk

Now that you are inside the VM command-line, you can use it as your server:

Steps on Ubuntu command-line:

Vagrant Path you need to know

  • /vagrant is the shared folder
  • ~ is /home/vagrant
  1. cd /vagrant (This is by default shared with the host)
  2. mrt create ~/meteorapp-placeholder (create a placeholder meteor app that's in another location, which will be used to hold .meteor folder for our app)
  3. mrt create meteorapp && cd meteorapp && rm -rf .meteor && mkdir .meteor/ (Check your Windows folder you’ve created. It will be there!)
  4. Input these lines: (/home/vagrant is the default path for home ~ in step 2)
sudo mount --bind /home/vagrant/meteorapp-placeholder/.meteor/ /vagrant/meteorapp/.meteor/
echo "sudo mount --bind /home/vagrant/meteorapp-placeholder/.meteor/ /vagrant/meteorapp/.meteor/" > ~/.bashrc && source ~/.bashrc
meteor
  1. Go to http://localhost:3000 in Windows browser and see it running! :)

The point here is to use the .meteor folder of your app pointing to another place (~/meteorapp) inside the VM (run ls -la .meteor/ on command-line and you will see the symbolic link), so Meteor uses the VM folder, not Windows folder, and won’t have permissions problems. You will also need to do all git flow inside Ubuntu command-line, because Windows can’t follow those links.

Hints:

  • Make sure you do version control INSIDE THE VM, so the software can follow the symlink.
  • To halt a vagrant VM: vagrant halt
  • To restart a vagrant VM without running all Meteor installation again: vagrant reload --no-provision or just remove the shell path you’ve put on Vagrantfile on line 10.
  • To destroy a VM: vagrant destroy

That’s it. There's a project that does it automatically in win.meteor.com

original author

@gabrielsapo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment