Wednesday, December 5, 2012

Guide to have a Rails Environment in Linux without Root access

I'm working today in a Linux server without root access and completely out of date. Following instructions in my post to Install a RoR Environment in Ubuntu does not work now, so this is what I did:

Bash was out of date (version 3.1) and RVM require version above 3.2. The procedure is to download the bash source, compile it and install it in your home directory. Then make sure it is selected instead of the previous bash version.

wget http://ftp.gnu.org/gnu/bash/bash-4.1.tar.gz
tar xzf bash-4.1.tar.gz
mkdir -p $HOME/usr/local
cd $HOME/bash-4.1
./configure --prefix=$HOME/usr/local/; make; make install
echo 'export PATH=$HOME/usr/local/bin:$PATH' >> .bashrc
. $HOME/.bashrc
echo "$BASH_VERSION"

You may also change your prompt adding \v to your PS1 variable to display the bash version running.

The curl version was also out of date and as it is required by RVM and the installation process. To update it go to http://curl.haxx.se/download.html and get the URL of the version you want to install.

wget http://curl.haxx.se/download/curl-7.28.1.tar.gz
tar xzf curl-7.28.1.tar.gz
cd curl-7.28.1
./configure --prefix=$HOME/usr/local; make; make install
curl --version

Git was not installed and without root I cannot use apt-get neither other package manager. To install it from the source go to http://code.google.com/p/git-core/downloads/list select the latest version or the one you want. Then:

wget http://git-core.googlecode.com/files/git-1.8.0.1.tar.gz
tar xzf git-1.8.0.1.tar.gz
cd git-1.8.0.1
./configure --prefix=$HOME/usr/local; make; make install
git --version

With Bash, Curl and Git now is time to install RVM:

curl -L get.rvm.io | bash -s stable
source $HOME/.rvm/scripts/rvm
#Check RVM is installed correctly. The output should be: rvm is a function
type rvm | head -1
rvm notes
rvm requirements

Check the dependencies and install the dependencies you don't have. In my case I had to install libyaml

Install libyaml:
Go to http://pyyaml.org/wiki/LibYAML and copy the URL of the libyaml source file.
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
tar xzf yaml-0.1.4.tar.gz
cd yaml-0.1.4
./configure --prefix=$HOME/usr/local/; make; make install

Install readline and readline-devel
wget ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz
tar xzf readline-6.2.tar.gz
cd readline-6.2
./configure --prefix=$HOME/usr/local/; make; make install

Install autoconf
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xzf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=$HOME/usr/local/; make; make install

Install libtool
wget http://mirrors.axint.net/repos/gnu.org/libtool/libtool-2.4.tar.gz
tar xzf libtool-2.4.tar.gz
cd libtool-2.4
./configure --prefix=$HOME/usr/local/; make; make install

Now you may continue with the ruby and rails installations.

#List the availables rubies
rvm list known
#Install the latest or the version you need
rvm install 1.9.3
#Set it as the default version to use
rvm use 1.9.3 --default
#Generate shebang wrappers
rvm tools rvm-env ruby bash
#Install Rails
gem install rails

I'll use SQLite so I do not need MySQL neither PosgreSQL. As SQLite was already there (Version 3.3.6) I am (or should) be ready to start Railing.

Source:

TODO's:

The installer cannot find libyaml. I still need to find a way to make rvm find it in my $HOME/usr/local/lib directory. Any suggestion?

I still need to check if the following dependencies are installed or not:
  • zlib
  • zlib-devel
  • libffi-devel
  • iconv-devel
Post a Comment