Skip to content

Instantly share code, notes, and snippets.

@wathiede
Last active December 27, 2015 20:59
Show Gist options
  • Save wathiede/7388339 to your computer and use it in GitHub Desktop.
Save wathiede/7388339 to your computer and use it in GitHub Desktop.
Setting up a VM with vagrant for jekyll.
# Jekyll Setup
## Download:
### Vagrant:
Latest at http://downloads.vagrantup.com/
- http://files.vagrantup.com/packages/a40522f5fabccb9ddabad03d836e120ff5d14093/Vagrant-1.3.5.dmg
Open .dmg and run installer.
### VirtualBox:
Latest at https://www.virtualbox.org/wiki/Downloads
- http://download.virtualbox.org/virtualbox/4.3.2/VirtualBox-4.3.2-90405-OSX.dmg
Open .dmg and run installer.
## Open terminal and run:
$ mkdir jekyllvm # This is will be the shared folder for the VM.
$ mkdir jekyllvm/www # This where you'll edit your site.
$ cd jekyllvm # Change into the new dir...
$ open www # and open it in Finder.
## Create a Vagrantfile
Run:
$ cat > Vagrantfile # Create the vagrant config.
Then copy and paste the following text into the terminal, and hit crtl-d when done:
Vagrant::Config.run do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.forward_port 4000, 4000
config.vm.provision :shell,
:inline => "sudo apt-get -y install build-essential ruby1.9.1-dev && grant_ruby/bin/gem install jekyll --no-ri"
end
## Start it up!
Now setup and start a virtual machine:
$ vagrant plugin install vagrant-vbguest
$ vagrant up # This will take a while on the first time.
$ vagrant ssh # This will ssh you into the VM you just started.
vm$ cd /vagrant
vm$ jekyll new www # Create new jekyll site.
vm$ cd www
vm$ jekyll serve -w # Run the webserver.
Now visit [http://localhost:4000](http://localhost:4000) with the web browser on your Mac.
## Cleanup:
When done, hit ctrl-c to stop jekyll, ctrl-d (or run 'exit') to logout.
To shutdown your vm, run:
$ vagrant halt
## Known issues:
- `jekyll serve -w` doesn't seem to detect files changed by an editor on the Mac, although it detects changes made inside the VM fine. Looks like https://www.virtualbox.org/ticket/10660?cversion=0&cnum_hist=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment