1. Prepare the library used for installation
$ Sudo apt-Get install GCC g ++ build-essential libssl-dev libreadline5-dev zlib1g-dev Linux-headers-generic
2. Download ruby1.9.2 source code compilation and Installation
$ wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
(If you ca n’t download, you can choose: http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2- p0.tar.bz2, http://ftp.ruby-lang.org/ pub / ruby / 1.9 / ruby-1.9.2-p0.zip)
$ tar -xvzf ruby-1.9.2-p0.tar.gz
$ cd ruby-1.9.2-p0 /
$ ./configure --prefix = / usr / local / ruby
$ make && sudo make install
3. Prepare Environment Variables
$ sudo gedit /etc/environment
Add Environment Variables
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ruby/bin"
Note: You can also modify the/etc/profile file to add/usr/local/Ruby/bin.
4. Check Ruby Installation
$ Ruby-V
Ruby 1.9.2p180 (Revision 30909) [i686-linux]
5. Create Association
$ sudo ln -s /usr/local/ruby/bin/ruby /usr/local/bin/ruby
$ sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem
If there is a symbolic connection gem under the/usr/bin/directory, delete the gem. Re:
$ Sudo ln-S/usr/local/Ruby/bin/gem/usr/bin/gem
6. Install rails
$ sudo gem install tzinfo builder memcache-client rack rack-test erubis mail text-format bundler thor i18n
$ sudo gem install rack-mount
$ sudo gem install rails
Wait patiently ....
7. Check the rails Installation
$ Source/etc/environment $ rails-V
Normally, rails 3.0.7
8. If you use a MySQL database
$sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby
$sudo gem install mysql
If the SQLite database is used:
$sudo apt-get install libsqlite3-dev build-essential
$sudo gem install sqlite3-ruby
9. If you want to install the spree framework
$ Sudo gem install spree
10. Create an application for testing
For MySQL
$rails new xxx -d=mysql$cd xxx
Configure MySQL and open the config/database. yml file:
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
Configure your username and password.
To use the spree framework, edit gemfile and add a gem 'spree'
$ bundle install
$ rake db: create
$ rails server // or $ rails s
Open http: // localhost: 3000 in the browser.
Environment configuration is complete.
Thanks http://www.cnblogs.com/msblog/archive/2011/03/08/1977407.html