Install Ruby
Since the ruby version of the APT Package Manager in Ubuntu is too old, consider compiling the installation from the source code. Here is an example of installing ruby2.3.0:
sudo Install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-/tmpwget HTTPS://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gztar -xvzf ruby-2.3 . 0. Tar . GZ CD ruby-2.3.0/. /Configuremakesudomakeinstall
After the installation is complete, we can view its version:
$ ruby-2.3. 0p0 (-53290) [I686-linux]
Installing Sqlite3
sudo Install sqlite3 Libsqlite3-dev
Installing Rails
Due to GFW, Ruby's default gem source rubygems.org is inaccessible, so you need to change the source first.
To view the current gem Source:
$ gem Sources-L* * * * Current SOURCES * * *https://rubygems.org/
Change Source:
$ gem sources-r https://rubygems.org/https://rubygems.org/removed from sources$ Gem sources-a https://ruby.taobao.org/https://ruby.taobao.org/added to sources $ gem Sources-L* * * * Current SOURCES * * *https://ruby.taobao.org/
Installing rails:
sudo Install Rails
When the installation is complete, view its version:
$ rails--4.2. 5.2
Modify Gemfile
Edit Gemfile:
sudo VI /usr/local/lib/ruby/gems/2.3. 0/gems/railties-4.2. 5.2/lib/rails/generators/rails/app/templates/gemfile
The first line
' https://rubygems.org '
Switch
' https://ruby.taobao.org/ '
Installing the JavaScript runtime
Here you choose to install Nodejs:
sudo Install Nodejs
Build Rails Engineering
Rails New Demo
Go to the folder and start the server:
CD demo/Rails server
Ubuntu builds Ruby on Rails environment