Install Ruby on Rails on Ubuntu [go] Source: Ubuntu community Author: Cheng guyun

Source: Internet
Author: User
Tags sqlite database

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.