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:
- Download VirtualBox: https://www.virtualbox.org/wiki/Downloads (Vagrant runs on top of VirtualBox, so you need it)
- Download latest Vagrant: http://downloads.vagrantup.com/
- Download git: http://git-scm.com/download/win (It will install ssh binaries required by Vagrant and let you connect to the VM)
- Create a folder to store your Vagrant files + Meteor project
- Download this script and save it as meteor.sh into that folder: https://gist.github.com/gabrielhpugliese/5471763/raw/6bc6f616842c75669d1c6f28ce7cd714fa28967e/meteor.sh UPDATE (use node 0.10.11)
#!/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
- Go to Start Menu > Type cmd > SHIFT + ENTER (to login as Administrator)
cd C:\path\to\your\vagrant+meteor\project\folder
set PATH=%PATH%;C:\Program Files (x86)\Git\bin
(Append git binaries to path so vagrant can run ssh)vagrant init precise32 http://files.vagrantup.com/precise32.box
(To install Ubuntu 10.04 x86)- 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
vagrant up
(It will download box, configure meteor and get it up)vagrant ssh
(It will connect on the VM and expose its command-line). Or you can use PUTTY to ssh into it.- the default user and pw is 'vagrant'
- 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:
Vagrant Path you need to know
/vagrant
is the shared folder~
is/home/vagrant
cd /vagrant
(This is by default shared with the host)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)mrt create meteorapp && cd meteorapp && rm -rf .meteor && mkdir .meteor/
(Check your Windows folder you’ve created. It will be there!)- 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
- 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.
- 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