1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windows10でWSLにRubyOnRailsの環境構築

Last updated at Posted at 2020-03-08

#WSLでRubyOnRailsを構築する

##WSL有効化
Windowsの機能の有効化または無効化を開く
image.png

Windows Subsystem for Linuxにチェックを入れる
image.png

##Ubuntuのインストール
Microsoft Storeを開く
image.png

ubuntuを検索する
image.png

入手してインストールする
image.png

起動してユーザー名とパスワードを設定する

##Ubuntuの設定

$ sudo apt update
$ sudo apt upgrade -y
$ sudo vim /etc/locale.gen (ja_JP.UTF-8に変更)
$ sudo locale-gen
$ sudo apt-get install language-pack-ja
$ sudo update-locale LANG=ja_JP.UTF-8
$ ln -s /mnt/c/src ~/src

##rbenvインストール

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ rbenv -v
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

##RubyとRailsのインストール

$ sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev
$ rbenv install 2.6.5
$ rbenv global 2.6.5
$ ruby -v
$ gem update --system
$ gem -v
$ gem install bundler
$ gem install rails
$ rails -v

##nodeインストール

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

##postgresqlのインストール

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt update
$ sudo apt install postgresql
$ psql -V
$ sudo service postgresql start
$ sudo su postgres -c 'createuser -s login_username'
$ psql postgres (¥qで抜ける)
$ sudo apt install libpq-dev
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?