2018年2月13日火曜日

Windows Subsystem for Linux and Ruby on Rails set up

Windows subsystem for Linux WSL enable us to run Linux binaries on Windows 10.
Microsoft provide Ubuntu, open SUSE leap42, and SUSE Linux Enterprise server on windows store.
The installation is very easy now.
The Linux subsystem would be really great new feature on Windows, since the web development requires many open source web app frame works, for example Ruby on Rails, django, play framework and more new web technology tend to be based on Linux/Unix environment. that is one of the reason that many professional developers use Mac for their work machine.

The below is my set up on Ruby on Rails with Windows subsystem Ubuntu.
Assume ubuntu is already ready and running.
You need to install git, python, libssl .....
install necessary using apt-get like

$sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev


Install rbenv
https://github.com/rbenv/rbenv
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ cd ~/.rbenv && src/configure && make -C src

add ~/.rbenv/bin  to bash Path

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

Run init

$~/.rbenv/bin/rbenv init

to update rbenv

$ cd ~/.rbenv
$ git pull


Install ruby-build
https://github.com/rbenv/ruby-build
$git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc


$rbenv install 2.5.0
$rbenv global
2.5.0




after checking if ruby has been installed successfully by ruby -v.
install bundler


 $gem install bundler

install node.js
https://github.com/nodesource/distributions

$curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$sudo apt-get install -y nodejs


install rails

$gem install rails
$rails -v

Let's create myWebService 


$ rails new myWebService

it takes a little bit of minutes...
after everything was done, type below to start the service.


$ rails server

when it says


=> Booting Puma
=> Rails 5.1.5 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.11.2 (ruby 2.5.0-p0), codename: Love Song
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000

go to the  http://localhost:3000.  ' You are on Rails' will be shown in the page and Rails works perfect. 

0 件のコメント:

コメントを投稿