A guide to setting up a Ruby on Rails development environment
We will be setting up a Ruby on Rails development environment on Ubuntu 14.04 Trusty Tahr.
The reason we're going to be using Ubuntu is because the majority of code you write will run on a Linux server. Ubuntu is one of the easiest Linux distributions to use with lots of documentation so it's a great one to start with.
Setup the Ubuntu environment:
The first step is to install some dependencies for Ruby.
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
Intall RVM
First step install some dependencies for rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash
#just incase you got error "Failed to connect to get.rvm.io port 443: Network is unreachable" run the script below
echo ipv4 >> ~/.curlrc
\curl -sSL https://get.rvm.io | bash
#after installing run the script below
source /home/marcelo/.rvm/scripts/rvm
Install Ruby
install ruby using rvm (Ruby Version Manager)
rvm install ruby-2.3.0
rvm use 2.3.1 --default
# to check which ruby version is installed
rvm list
# to check which gemset is installed
rvm gemset list
Install Rails
Since Rails ships with so many dependencies these days, we're going to need to install a Javascript runtime like NodeJS. This lets you use Coffeescript and the Asset Pipeline in Rails which combines and minifies your javascript to provide a faster production environment.
To install NodeJS, we're going to add it using the official repository:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# installing rails
gem install rails -v 4.2.6
After installing, now you can run the rails -v
rails -v
Now you can create a new project
rails new railsapp
cd app
rails s
#you can see now the welcome screen..
0 comments:
Post a Comment