Last active
December 30, 2015 06:49
-
-
Save aghyad/7792256 to your computer and use it in GitHub Desktop.
Installing ruby2 rails4 with nginx passenger WITH rbenv on ubuntu 12.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you have a packaged ruby / rails / rvm / rbenv etc installed, get rid of them all, eg: | |
$ ruby --version | |
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] | |
$ sudo apt-get remove ruby | |
if that didn't work, you can do: | |
$ aptitude purge ruby | |
or to specify the ruby version installed to uninstall it: | |
$ dpkg -l | grep ruby | |
then: | |
$ aptitude purge ruby.X.X.X | |
Don't use rvm; and make sure it's been literally purged from your system. It's a pain to remove as it gets into all sorts of places and even apt-get purge doesn't undo changes to the profile etc. If you want to know more about the reason for not using it then read the rbenv "why" page, it's persuasive stuff. | |
My recommendation from experience so far is to use rbenv to install the latest and greatest RoR (Ruby on Rails). Don't bother with the ubuntu packaged version of rbenv (from apt etc) as you'll be off the beaten track and will have to figure out the ruby-build plugin installation yourself. The local user install is painless and works well. The instructions say to make sure rvm is removed first as it's incompatible. | |
Sidenote, http://rbenv.org/ is just a one-click link to https://github.com/sstephenson/rbenv | |
Direct link to rbenv readme (for your convenience) | |
rbenv installation | |
Install rbenv into your home directory: | |
$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv | |
Set up the environment as per the (ubuntu specific) rbenv installation instructions: | |
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile | |
$ echo 'eval "$(rbenv init -)"' >> ~/.profile | |
Unless you've done anything before, there is no ~/.profile file before hand, so the contents will then be: | |
$ cat ~/.profile | |
export PATH="$HOME/.rbenv/bin:$PATH" | |
eval "$(rbenv init -)" | |
Restart the login shell: | |
$ exec $SHELL -l | |
Check rbenv is now available: | |
$ rbenv | |
rbenv 0.4.0-45-g060f141 | |
Usage: rbenv <command> [<args>] | |
... | |
Set up the ruby-build plugin (as linked in the rbenv readme) | |
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build | |
Install the necessary ssl library: | |
$ sudo apt-get install libssl-dev | |
If you don't install the openssl development libraries you get this: | |
BUILD FAILED | |
... | |
The Ruby openssl extension was not compiled. Missing the OpenSSL lib? | |
Ruby installation | |
Install the latest ruby (version name obtained from release info on ruby blog), takes 5-10 mins | |
$ rbenv install 2.0.0-p0 | |
Now select the installed ruby as the default for your user (ref: https://github.com/sstephenson/rbenv#choosing-the-ruby-version) | |
$ rbenv global 2.0.0-p0 | |
tim@atom:~$ ruby --version | |
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux] | |
Rails installation | |
Now as per the Rails 4 RC1 announcement install the release candidate of Rails 4 (this was the latest at time of writing). Takes 5-10 mins. | |
$ gem install rails --version 4.0.0.rc1 --no-ri --no-rdoc | |
Tell rbenv to create the new shims and see the installed rails: | |
$ rbenv rehash | |
$ rails --version | |
Rails 4.0.0.rc1 | |
============== | |
capistrano deployment: | |
add the gem to your Gemfile: | |
gem 'capistrano' , '~> 2.15.5' | |
Then, | |
$ Capify . | |
Then, make sure to include the following line to deploy.rb to enable rbenv with capistrano: | |
set :default_environment, { | |
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" | |
} | |
And don't forget to add the .ruby-version file to your app base directory with the version of ruby you installed in the server. | |
============== | |
Sources: | |
- http://timwise.blogspot.com/2013/05/installing-ruby-2-rails-4-on-ubuntu.html | |
- http://stackoverflow.com/questions/3957730/how-can-i-uninstall-ruby-on-ubuntu | |
- http://henriksjokvist.net/archive/2012/2/deploying-with-rbenv-and-capistrano/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment