Skip to content

This is a simple repository to help practice setting up Vagrant for a portable Ruby on Rails development virtual machine and being able to deploy to a remote service; such as Heroku.

Notifications You must be signed in to change notification settings

Sonna/setup_vagrant_rails_and_cap_deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to setup Vagrant, Ruby on Rails and deploying with Capistrano

The purpose of this repository to practice setting up a virtual environment through Vagrant, for developing a Rails application and then deploying the application to a remote service (like Heroku) via Capistrano.

This is also for use for fellow students to learn from and copy.

Step 1

First download and install the following programs:

You will need Git to clone repositories, but also to use its included "Git bash" if you are running on Windows and do not have some basic Linux plugins installed (via MinGW, Cygwin, etc).

Step 2

In order to quickly setup the developer environment find a premade manifeat or recipe to use in Vagrant for installing the appropraite software, like MySQL for databases and Apache for serving webpages or applications.

*Note: Any premade Vagrant box will by default have Ruby installed, to allow provisioners like Chef or Puppet to run and install software.

For this Project I will be following SpinUpLabs' Vagrant: Rails development environment article and using their Vagrant file and Puppet manifest to quickly start building an ideal Ruby on Rails developer environment.

Step 2 - Alternative

Alternatively you could chose to configure your Vagrant install with something like SaltStack. which is a great alternative if you find Chef and Puppet hard to configure or too slow.

SaltStack is Python based script that uses YAML files for configuration manifests. To use it with Vagrant you will need to install Salty Vagrant by running vagrant plugin install vagrant-salt after installing Vagrant.

Quickly searching the web found the "Red Tide Hobo Surfer" repositroy, which should install and setup a Rails environment using SaltStack.

Step 3

Download and copy your chosen Vagrant file, with provision manifests, into the project's root folder.

Step 4

Change to the project's root directory in Terminal (Linux or Mac OS X), Git bash or Command Prompt as Admin (Windows);

e.g. cd ~/My\Documents/GitHu/setup_vagrant_rails_and_cap_deploy/

Run the command vagrant up

This will download the appropriate Vagrant box, a virtual machine built for use with Vagrant, and install the software listed in the manifests.

*Note: This will take some time and may fail from timing out when installing some packages. If that happens restart the virtual machine with vagrant reload. This also useful for making changes take affect after updating the configure manifests.

Step 5

After the installation has finished, login into the virtual machine with vagrant ssh.

*Note: SSH will NOT work in Windows' Command Prompt without additional tools like Cygwin. I would recommend downloading Git and using its Git bash

Step 6a

Once logged in run the command gem install bundler .

Bundler is a Ruby Gem for managing Gems and their dependencies, ensuring that they will all work with another despite version differences.

Step 6b

Install Ruby on Rails

gem install rails

*Note: If installing any Gems is taking an unsually long time, Ctrl+c to cancel out and try again or add -V (case-sensitive) or --verbose to get the full output what it is doing whilst it installs.

Step 7

Generate a new Rails Application; e.g.

rails new blog

Step 8

Change into the new project directory; e.g.

cd /vagrant/blog/

Create the database

rake db:create

And start the server

rails server

References:

Articles

Repositories

Software/Tools

others

About

This is a simple repository to help practice setting up Vagrant for a portable Ruby on Rails development virtual machine and being able to deploy to a remote service; such as Heroku.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published