Skip to content

VagrantでUbuntu 18.04の開発環境を用意する

ShinyaKato edited this page May 20, 2018 · 3 revisions

VirtualBoxとVagrantをインストール

VitualBox: https://www.virtualbox.org/
Vagrant: https://www.vagrantup.com/

適当なディレクトリでVagrantfileを作成する

vagrant init bento/ubuntu-18.04

Vagrantfileを適宜修正する

以下自分がやっていた設定を参考までに。

private IPアドレスは固定する方が楽。
後でブラウザからアクセスするときはこのIPでアクセスできる。
参考: https://www.vagrantup.com/docs/networking/private_network.html

メモリは少し増やした方がいいと思う。
メモリ少ないとWebpackのトランスパイルでこけることがあった。
自分は2048MBにしていた。

あと、お好みでsshのforward agentを設定をすると仮想マシンの中からホストの秘密鍵を使える。
GitHubに新しく鍵を追加しなくて良いので便利。
Macならssh-add -K ~/.ssh/id_rsaでssh agentに鍵を追加できる。

# コメントインする
config.vm.network "private_network", ip: "192.168.33.10"

# コメントインする
config.vm.provider "virtualbox" do |vb|
  # Display the VirtualBox GUI when booting the machine
  # vb.gui = true

  # Customize the amount of memory on the VM:
  vb.memory = "2048"  
end

# 追記する
config.ssh.forward_agent = true

VMを立ち上げて、sshでログインする

vagrant up
vagrant ssh

あとはREADMEの通りに進める