Super easy Rails deployment with Ubuntu 12.xx

1. Install Ruby Using RVM

$ \curl -L https://get.rvm.io | bash -s stable –ruby

Some info you will get. This will install latest ruby 2.1

No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.1.0 – #extracting rubygems-2.2.2.
ruby-2.1.0 – #removing old rubygems.
ruby-2.1.0 – #installing rubygems-2.2.2……………
ruby-2.1.0 – #gemset created /usr/local/rvm/gems/ruby-2.1.0@global
ruby-2.1.0 – #importing gemset /usr/local/rvm/gemsets/global.gems…..
ruby-2.1.0 – #generating global wrappers.
ruby-2.1.0 – #gemset created /usr/local/rvm/gems/ruby-2.1.0
ruby-2.1.0 – #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.1.0 – #generating default wrappers.
Creating alias default for ruby-2.1.0.

* To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
root@amios:/home/ami#

and DO NOT FORGET ABOUT THIS 🙂 otherwise if you type ruby -v nothing will happened.

$source /usr/local/rvm/scripts/rvm

2. Install Node.js – This is very important to make your live easier.

root@amios:/home/ami# apt-get install nodejs
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
dbconfig-common libmcrypt4 php5-mcrypt
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
libc-ares2 libev4 libv8-3.8.9.20
The following NEW packages will be installed:

If you don’t install Node.js, you’ll need to add this to the Gemfile for each Rails application you build:

gem ‘therubyracer’

3. Do some checking

root@amios:/home/ami# ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]

root@amios:/home/ami# gem -v
2.2.2 ( To update to latest version type gem update –system

4. Upgrade to make your PC happy.

root@amios:/home/ami# rvm gemset list

gemsets for ruby-2.1.0 (found in /usr/local/rvm/gems/ruby-2.1.0)
=> (default)
global

root@amios:/home/ami# rvm gemset use global
Using ruby-2.1.0 with gemset global
root@amios:/home/ami# gem list

root@amios:/home/ami# gem outdated
bigdecimal (1.2.3 < 1.2.5)
minitest (4.7.5 < 5.2.2)
psych (2.0.2 < 2.0.4)
rake (10.1.0 < 10.1.1)
rdoc (4.1.0 < 4.1.1)
test-unit (2.1.0.0 < 2.5.5)

oot@amios:/home/ami# gem update
Updating installed gems
Updating bigdecimal…………………..

5. Speed up gem installation if you dont need doc files ???

$ echo “gem: –no-document” >> ~/.gemrc

6. Install your Rails. As everybody recommends create a new gemset with current rails version.++

root@amios:/home/ami# rvm use ruby-2.1.0@rails4.0 –create
ruby-2.1.0 – #gemset created /usr/local/rvm/gems/ruby-2.1.0@rails4.0
ruby-2.1.0 – #generating rails4.0 wrappers.
Using /usr/local/rvm/gems/ruby-2.1.0 with gemset rails4.0
root@amios:/home/ami# gem install rails

Fetching: atomic-1.1.14.gem (100%)
Building native extensions. This could take a while…
Successfully installed atomic-1.1.14
Fetching: thread_safe-0.1.3.gem (100%)
Successfully installed thread_safe-0.1.3
Fetching: tzinfo-0.3.38.gem (100%)
Successfully installed tzinfo-0.3.38
Fetching: multi_json-1.8.4.gem (100%)
Successfully installed multi_json-1.8.4……………..

7. Don’t use beta versions. Always stable and make your life easier!

8. Don’t user root account for developemnt 🙂

9.root@amios: adduser nOObdeveloper or ami 🙂

10. Create a project folder@

ami@amios:~$ cd ~
ami@amios:~$ ls
ami@amios:~$ cd ~
ami@amios:~$ mkdir workspace
ami@amios:~$ mkdir workspace/rails_projects

rvm does not exist ??? wth

ami@amios:~$ source /usr/local/rvm/scripts/rvm (hmmm…. easy to forget /???? )
ami@amios:~$ rvm -v

rvm 1.25.17 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

ami@amios:~$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]

ami@amios:~$ rvm gemset use rails4.0 – you want to use your gemset don’t you ???
Using ruby-2.1.0 with gemset rails4.0

Now you can create your rails applications using gemset per apps

$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.1.0@myapp –ruby-version –create
$ gem install rails
$ rails new .

Finally we run rails new .. We use the Unix “dot” convention to refer to the current directory. This assigns the name of the directory to the new application.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s