Part1. Set up environments for Ruby on rails on Linux server
Hi guys, welcome to my blog for ruby on rails. I am pleasure to talk with you guys about ruby on rails. Before I talk about detail of Ruby on Rails, let’s start with building a development environment.
To install ruby and rails on your laptop, I am going to use Ubuntu Linux that is used in OS course. If you don’t want to use it for Ruby on rails, I am welcome to use any version of Linux, but I recommend to use Ubuntu or Debian Linux. This is because the installation commands may differ depending on the operating system. As a prerequisite, you need to have a basic knowledge of the Linux operating system, such as how to use basic commands and how to use the vi editor.
1.1 Installing Ruby on Ubuntu Linux
First, let’s proceed with installing Ruby assuming everyone is using the Ubuntu Linux operating system. To install Ruby on Rails, you need to install a manager program called RVM first. The Ruby Version Manager (RVM) is a service that makes it easy to install Ruby. This RVM is a program that simplifies the installation process of Ruby, and also makes it possible to manage multiple versions of Ruby simultaneously. To install Ruby easily, you need to install RVM first. After running Chrome, you can browse RVM in Google or go to the following link: https://rvm.io

The same screen as the above screen shot will appear. You must copy the commands in the red box to the screenshot.
$ \curl -sSL https://get.rvm.io | bash -s stableHowever, If you try to use this command, the following error occurs. This is because we do not have a program to run curl on Linux.

Do not panic, the following command will install the curl program.
$ sudo apt-get update
$ sudo apt-get install curlThen, If you run the previous command after installing curl, as shown in the figure below, a brilliant message pops up and RVM installation is completed.

Then type the following on the terminal and press Enter:
$ source .bash_profileNow it is time to install Ruby in earnest using RVM. On the terminal, type the following and press Enter:
$ rvm install 2.0.0It means I will install Ruby 2.0.0. This will start the installation with a more brilliant screen as shown below. It will take some time to complete the installation, so let’s wait:

To verify that Ruby is installed correctly, type the following command and press Enter:
$ ruby -vIt is a command to check the installed version of Ruby. If it comes out as shown below, it is properly installed!

1.2 Installing Rails on Ubuntu Linux
Now that you’ve installed Ruby, it’s time to install Rails. Rails is the most widely used server framework based on the Ruby language.
To install Rails, type the following on the terminal and press Enter:
$ gem install rails --version 4.0.1 --no-ri --no-rdocIt means I will install version 4.0.1 of Rails. That — no-ri — no-rdoc suffixed is meaning that they would not install various manuals and documents related to Rails. This will speed up the installation of Rails. At first, it seems like no message appears, but you have to wait with faith.
If you see ‘Successfully installed rails-4.0.1’ at the end of the screen as shown below, you have successfully completed the installation.

To verify that Rails is properly installed, type the following command and press Enter:
$ rails -vIt is a command to check the version of installed Rails. If it comes out as shown below, it is properly installed:

1.3 Creating a Rails project and running the server
To test whether Rails works properly, I will create a Rails project. The ‘project’ here is the unit of the web service that you will be building in the future.
To create a new Rails project first, type the following on the terminal and press Enter:
$ rails new project1 --skip-bundleThis will create a new Rails project directory as shown below:

Enter the project directory you just created:
$ cd project1Next, you need to add some content to a file named Gemfile in the current project directory. On the terminal, type the following and press Enter:
$ echo "gem 'therubyracer'" >> GemfileThe meaning of this command will be explained in another post. Next, type the following on the current project directory and press Enter.
$ bundle installIf the command is executed normally, you can see ‘Bundle completed!’ Message at the end of the screen as shown below.

Note
If you have any error while installing bundle, you should try this code:
sudo apt-get install g++
And try bundle install again. It will be solution for this problem.
Now it is time to run the server properly. So far, the process of connecting to the server and making a series of settings has been a preparation for running the server. From the moment you start the server on the project directory, it receives the client’s request and delivers the service you created to the client.
To run the server, type the following command in the current project directory and press Enter.
$ rails sThe server is started for the project by rails s command. At this time, the server automatically exchanges requests with the client through port 3000. If the server is running normally, you can see the message shown below

Now run Browser, type ‘localhost: 3000’ in the address bar and hit enter. If the screen shown below is successful, All of setting is done successfully.

If you want to stop running the server, press Ctrl + c in this state. Then the server will stop running with the following message:

