Configuration of Ruby on Rails Framework and RubyMine IDE Development Environment on Ubuntu

Time:2019-3-27

Fragmentation in the preparatory stage

During the installation of virtual box, there are many pits for one reason or another.

Pit 1,With regard to terminals, be sure to use the starter to open them

After installing the virtual machine and entering the system, we will encounter the first pit, terminal software. It is recommended that everyone use the starter to open the terminal.

Never use the file manager to enter the folder, and then right-click “Open in the terminal”. At this time, environment variables can not be loaded, especially when non-desktop folders enter. The terminal can not load environment variables, most of the software can not be executed in the terminal.

When you open the terminal, you must go through the starter, which is the sidebar on the left side of the desktop in bantu, much like the shortcut in windows.

Pit 2,As for assumptions, most websites assume that you have some basic packages or software installed, but not to mention, which makes it particularly difficult for beginners to build environments.

Solution: Manual installation of software, commands:

Apt-get install package name

In China, due to various reasons, software installation overtime.

In the process of installation below, if the server refuses positively, 80% of the possibility will be wall. Or it’s blocked by the network of your company or home, or it’s a slow, half-day phenomenon. Congratulations, you have to change the source address.

RVM solution: after installing RVM to ensure that rvm-v can be executed, execute the following commands to replace server resource information


sed -i -e's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g'~/.rvm/config/db

Gem solution:

gem source

gem source -r https://rubygems.org/

Gem Source-A https://ruby.taobao.org/Add Taobao source

If the installation package is not found, update the random package manually:


sudo apt-get update

Installation steps

1. It is necessary to update random packages, otherwise there may be more than N errors below.


sudo apt-get update

2. Installing curl, we need to use it to install RVM


sudo apt-get install curl

3. Install rvm. We use RVM to install ruby, rails, etc. See: https://ruby-China.org/wiki/rvm-guide for RVM installation.

curl -L get.rvm.io | bash -s stable

// Unable to check signature: unable to find the public key, execute the following statement (a pit)

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

// Then, re-execute. After installing the rvm, you need to configure the terminal so that the next time you open the terminal, you can use only the RVM directly. Change terminal configuration: see https://rvm.io/integration/gnome-terminal

curl -L get.rvm.io | bash -s stable

// At this point, the installation of RVM is completed. Next, we manually configure the RVM environment for the terminal. Otherwise, we may have to manually load the RVM environment every time in the terminal.

// Change Terminal Configuration Method: Toolbar - Edit - Configuration File Preferences - Titles and Commands - Commands - Select "Run Commands as a Login Shell"

// Then, we manually load the RVM environment and change the server resources to Taobao's

/////// Source ~/. RVM / scripts / RVM official load RVM environment command, we will not execute

// Temporarily load the RVM environment, reference: https://rvm.io/integration/gnome-terminal

source ~/.bashrc

source ~/.bash_profile

// Change RVM source server resource information, after all, foreign countries are often walled off, and there is the domestic speed. If not set up, there may be a variety of problems, such as server positive rejection (wall), or slow download speed.

sed -i -e 's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g' ~/.rvm/config/db

// Please save your work and restart Ubuntu

sudo reboot

// After reboot, open the terminal and we can use rvm.

// List Ruby versions available on RVM remote servers

rvm list known

4. Install ruby, we choose the latest, without version number, that is to say, install the latest.

rvm install ruby

RVM use x.x.x -- default /// Set default version

If prompted


RVM is not a function, selecting rubies with 'rvm use ...' will not work.

Load the configuration file from scratch


source ~/.bash_profile

5. Next we need to use gem, before using it, switch to the Taobao server gem to use more. See: // View the current list of gem sources, the default source is


https://rubygems.org/

6. Install rails using gem

Gem install rails /// Install any dependency packages if there is a problem prompting the lack of any dependency packages

Then it’s time to officially start installing Ruby on rails

Ruby-v// View the Ruby Version

Rails-v//View rails version

The version starts to create the project without any problems, and 100 words are omitted here.

After the project is created, you need to install the JS compiler (sometimes you don’t need to know why, just to be sure, install it)


sudo apt-get install python-software-properties

sudo add-apt-repository ppa:chris-lea/node.js

sudo apt-get update

sudo apt-get install nodejs

Then start


 rails s 

If the launch is successful, you can view the website at http://localhost:3000

Installation of RubyMine under Ubuntu

1. Download JDK from official website and decompress it

You can decompress it manually or use the command line. It feels almost the same. Still feel better with the mouse.


$tar -xzvf jdk-8u20-linux-x64.tar.gz

2. Copy to usr/lib

Usually it is customary to put it under this directory, but of course it is not decided to store the directory according to your environment.


sudo cp-r ~/jdk1.8.0_20 /usr/lib/jvm

3. Configuring environment variables


sudo gedit ~/.profile

Add environment variables at the end of the document


export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_20

Then save and update to see if the addition was successful


source ~/.profile

env

The occurrence of JAVA_HOME variable and its consistency with the added directory indicates that the environment variable has been successfully modified.

3. Modify the default JDK

$sudoupdate-alternatives --install/usr/bin/java java /usr/lib/jvm/jdk1.8.0_20/bin/java300

$sudoupdate-alternatives --install/usr/bin/java java /usr/lib/jvm/jdk1.8.0_20/bin/javac300

$sudoupdate-alternatives --config java

$sudoupdate-alternatives --config javac
$java-version// Check if the Java version is a newly installed version?

4. Download rubymine on the internet, decompress it, enter bin, run. / rubymine. SH and open it.

Ding… Perfect.