Based On Rails-Dev-Box
- Development tools
- Git
- Ruby 2.2
- Bundler
- SQLite3, MySQL, and Postgres
- Databases and users needed to run the Active Record test suite
- System dependencies for nokogiri, sqlite3, mysql, mysql2, and pg
- Memcached
- Redis
- RabbitMQ
- An ExecJS runtime
- Foreman
- Middleman
For OSX/Linux/Windows
-
Download and Install Vagrant
-
Download and Install Virtualbox
-
Download and open/install the appropriate VM Virtualbox Extension Pack
-
Ensure git CLI on host machine
/// FOR WINDOWS ONLY SKIP AHEAD TO VAGRANT BOX SECTION IF USING OSX ///
-
Download and Install PuTTYgen puttygen.exe
$ git clone https://github.com/dannyvassallo/rails-middleman-vagrant.git
$ cd rails-middleman-vagrant
###Macintosh OS X
####Setting Memory and Processor Power in Vagrant
navigate to the cloned repo
cd rails-middleman-vagrant
Open 'Vagrantfile' with sublime text
Replace it's contents with these changing the number following v.cpus
to update the number of processor cores and changing the number following
v.memory
to your desired RAM specs.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'danny-rails-middleman'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true
config.vm.provider 'virtualbox' do |v|
v.cpus = 2
v.memory = 2048
end
end
If you've run vagrant up
before setting up your memory run:
$ vagrant destroy
$ vagrant up && vagrant provision
######Check Your Memory has been successfully changed
$ cd rails-middleman-vagrant
$ vagrant up
$ vagrant ssh
$ free -m
The total memory reported should match closely to the v.memory
inputted.
To Start up your VM
$ vagrant up
To SSH in to the VM:
$ vagrant ssh
Navigate to synced folders directory:
$ cd /vagrant
To suspend:
vagrant suspend
To halt:
vagrant halt
###Windows XP/7/8
####Setting Memory and Processor Power in Vagrant
navigate to the cloned repo
cd rails-middleman-vagrant
Open 'Vagrantfile' with sublime text
Replace it's contents with these changing the number following v.cpus
to update the number of processor cores and changing the number following
v.memory
to your desired RAM specs.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'danny-rails-middleman'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true
config.vm.provider 'virtualbox' do |v|
v.cpus = 2
v.memory = 2048
end
end
If you've run vagrant up
before setting up your memory run:
$ vagrant destroy
$ vagrant up && vagrant provision
######Check Your Memory has been successfully changed
$ cd rails-middleman-vagrant
$ vagrant up
FOLLOW PUTTY INSTRUCTIONS BELOW
$ free -m
The total memory reported should match closely to the v.memory
inputted.
To Start up your VM in cmd or powershell
$ vagrant up
-
Open puttygen.exe
-
Click the "Load" button
-
To the right of Filename at the bottom change the drop down from "PuTTy Private Key Files (.ppk)" to "All Files ()"
-
Navigate to the cloned repo folder (example 'Desktop/Websites/rails-middleman-vagrant')
-
Navigate to the "private_key" file in ".vagrant/machines/default/virtualbox/private_key" and click open on this file.
-
Click 'Ok' to the PuTTyGen alert window
-
Click "Save Private Key"
-
Click 'Yes' to the PuTTyGen alert window
-
Name the .ppk file "private_key" without quotes
-
Save it in the same directory as putty for organization
-
Close PuTTyGen
- Open putty.exe
- Set "Host Name (or IP address)" to "127.0.0.1"
- Set "Port" to "2222"
- Set "Connection Type" to "SSH"
- Check "Display pre-authentication banner (SSH-2 only)"
- Check "Attempt authenticating using Pageant"
- Check "Attempt "keyboard-interactive" auth (SSH-2)"
- Check "Allow agent forwarding"
- Check "Allow attempted changes of username in SSH-2"
- Click Browse and navigate to the "private_key.ppk" file you generated in the putty directory
- Type "vagrant" (no quotes) in the Saved Sessions input
- Click Save
To open the vagrant box from this point on you may skip the putty setup. You will only need to open the putty.exe file and double click "vagrant" in the saved sessions list after running "vagrant up" in cmd or powershell.
Navigate to synced folders directory:
$ cd /vagrant
To suspend:
vagrant suspend
To halt:
vagrant halt
Run:
$ lsof -i | grep LISTEN
If you see something listed like this:
VBoxHeadl 4405 my_name 18u IPv4 0xffffff802a933320 0t0 TCP *:hbci (LISTEN)
VBoxHeadl 4405 my_name 19u IPv4 0xffffff802bcf04e0 0t0 TCP localhost:rockwell-csp2 (LISTEN)
Run (replace 4405 with the number in your print out):
$ kill -9 4405
To check the process has been killed run:
$ lsof -i | grep LISTEN
The VBoxHeadl should be missing. You are good to now run:
$ vagrant up
Taken from here
update your config/database.yml with these DB credentials:
development:
…
username: coderelf
password: password
test:
…
username: coderelf
password: password
To enable Hstore:
change 'MY_DATABASE' to your database name.
$ sudo su postgres -c "psql MY_DATABASE -c 'CREATE EXTENSION hstore;'"
don't use rails s. use this instead:
$ bin/rails s -b 0.0.0.0
don't use middleman s. use this instead:
$ bundle exec middleman s --port=3000