Monday, November 25, 2013

Installing Ruby, RVM, Rails, Mysql, Mysql-Query-Browser,Chrome browser, Aptana, Sublime all in one

First of all, we're going to run `sudo apt-get update` so that we have the latest sources on our box so that we don't run into any package-related issues, such as not being able to install some packages.
Next, we're going to install curl, which we'll use to fetch the RVM script:
`sudo apt-get install curl`


RVM is a Ruby Version Manager created by Wayne E. Seguin and is extremely helpful for installing and managing many different versions of Ruby all at once. Sometimes you could be working on a project that requires an older (1.8.7) version of Ruby but also need a new version (2.0.0) for one of your newer projects. This is a problem that RVM solves beautifully.
Another situation could be that you want to have different sets of gems on the same version of Ruby but don't want to have to do deal with Gem Conflict Hell. RVM has gemsets for this.

With curl installed we'll be able to install RVM with this command:
`curl -L | bash -s stable --auto`

The beautiful part of this is that it installs RVM and Ruby to our home directory, providing a sandboxed environment just for us.
Then we'll need to reload the ~/.bash_profile file which we can do with this small command:

. ~/.bash_profile
The next command we run will tell us what other packages we need to install for Ruby to work:

`rvm requirements`
A couple of things to note in this is that the build-essential package is installed, which will install all the essential build tools for Ubuntu, so we'll be able to download and compile Ruby, amongst other things.
This will also install Git, which is a version control system tool that you should be using if you're not already. This is used by RVM to fetch the latest source for some versions of Ruby.

These packages will lessen the pain when we're working with Ruby. For example, the libssl-dev package will make OpenSSL support in Ruby work, libsqlite3-0 and libsqlite3-dev are required for the sqlite3-ruby gem and the libxml2-dev and libxslt-dev packages are required for the nokogiri gem.

Install all these packages now using this command:

`sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison  \
subversion pkg-config`


With RVM and these packages we can install Ruby 1.9.3 or 2.0.0:
`rvm install 2.0.0`
Once it's done, we'll have Ruby 2.0.0 installed. To begin using it we can use this lovely command:
`rvm use 2.0.0`

 Are we using 2.0.0? You betcha:
 `ruby -v`
 ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
To make this as a default ruby use the following command:  
`rvm --default use 2.0.0`
 As an additional side-note: Users can, and should, use a gemset when possible so that they don't pollute their 'default' which is what is selected when a gemset is not specified in either a project's .rvmrc, or at the command-line. Each installed Ruby has a '@global' gemset. This is used to share gems with other gemsets created under that specific Ruby, and with the 'default' gemset. This can be selected by running 'rvm gemset use global' and then installing the gems you wish to share to other gemsets including 'default'. You can, of course simply install in each gemset but this will cause needless duplication and use up more disk-space and bandwidth. 


Now that RVM and a version of Ruby is installed, we can install Rails. Because RVM is installed to our home directory, we don't need to use that nasty sudo to install things; we've got write-access! To install the Rails gem we'll run this command:
gem install rails -v 4.0.0
This will install the rails gem and the multitude of gems that it and its dependencies depend on, including Bundler.


If you're planning on using the mysql2 gem for your application then you'll want to install the libmysqlclient-dev package before you do that. Without it, you'll get an error when the gem tries to compile its native extensions.

And that's it! Now you've got a Ruby environment you can use to write your (first?) Rails application in with such minimal effort.

Chrome Browser

Download the current stable version from here. After downloading the “.deb” file, open a terminal and move to the directory where the debian file is downloaded. For example, if the file is in Downloads use the below command to move to the Downloads directory.

`cd Downloads
After changing the directory, use the below command to install the google chrome from debian file. Type the password for the user when prompted.

`sudo dpkg -i google-chrome-stable_current_i386.deb`

 If you find any error and the installation fails because of dependency Then try using the below command, type the password for the user when prompted.

`sudo apt-get -f install`

If you still find error in installing the pkg, try looking your `/tmp` folder, you will find multiple pkgs installed. Choose the required one and dpkg again 

Thats it..!!


Aptana Studio 3

1. Install the prerequisites

`sudo apt-get install openjdk-7-jdk libjpeg62 libwebkitgtk-1.0-0 git-core`
Although Aptana Studio doesn’t officially support OpenJDK, I’ve not encountered any problems, however I’ve not done extensive testing. Alternatively, to use the Sun JDK, do the following:

sudo apt-get install libjpeg62 libwebkitgtk-1.0-0 git-core
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer 

libjpeg62 pkg is important, without it you will get errors.

2. Download Aptana Studio

You can download Aptana Studio 3 here. Select the “Standalone Version” if not selected and click download.

3. Extract **Aptana Studio**

sudo unzip [name of Aptana Studio ZIP file here].zip -d /opt
4. Add the menu shortcut

sudo mv AptanaStudio3.desktop /usr/share/applications/AptanaStudio3.desktop
 And you are done..!!!
If you prefer sublime over aptana, here's how to get it on your machine.


After reading numerous blog posts about how to install Sublime Text 2 in Ubuntu, this is definitely the quickest way! Just paste the following lines into your Terminal:

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text
After running this, Sublime Text 2 has been installed within the /usr/lib/sublime-text-2 directory and can be launched from the Dashboard, or by typing subl, sublime-text or sublime-text-2 into a Terminal window.

No comments:

Post a Comment