Ubuntu comes with Ruby and Rails, but it is not the latest version. The Ruby version is about 1.9.1, but Rails version is only 2.3.5, Which is outdated, so you have to download the latest source code for compilation and installation. 1. Library $ sudoapt-getinstallgccg ++ build-essentiallibssl-devlibreadline5-devzlib1g-devlinux used to prepare for Installation
Ubuntu comes with Ruby and Rails, but it is not the latest version. The Ruby version is about 1.9.1, but Rails version is only 2.3.5, Which is outdated, so you have to download the latest source code for compilation and installation.
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 cannot 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"
Make environment variable effective
$ Source/etc/environment
4. Check Ruby Installation
$ Ruby-v
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
6. Install Rails
$ Sudo gem install tzinfo builder memcache-client rack-test erubis mail text-format bundler thor i18n
$ Sudo gem install rack-mount
$ Sudo gem install rails
7. Check the Rails Installation
$ Source/etc/environment
$ Rails-v
8. If you use a mysql database
$ Sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby
$ Sudo gem install mysql
If you use an sqlite Database
$ 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.