LoginSignup
0
1

More than 5 years have passed since last update.

vagrantの備忘録

Posted at

参考サイト
http://dotinstall.com/lessons/basic_localdev_mac_v2

インストール

vagrantをインストール
https://www.vagrantup.com/downloads.html

$ vagrant --version
Vagrant 1.9.5

初期化と起動

仮想マシン設定用のVagrantfileを作る(centOSの場合)

$ vagrant init bento/centos-6.8

Vagrantfileを編集して仮想マシンのIPアドレスを192.168.33.10にする

$ vim vagrantfile

#この文をファイルに書き込む
config.vm.network :private_network, ip:"192.168.33.10"

起動してみる

$ vagrant up

仮想マシンの状態を確認

$ vagrant status
default       running (virtualbox)

接続

$ vagrant ssh

[vagrant@localhost ~]$ 

こんなふうになれば成功

仮想マシンのセットアップ

osはインストールされましたがrubyやphpなどはインストースされていないので、色々インストールしていく。

#OSを最新状態にアップデート(時間かかります)
[vagrant@localhost ~]$  sudo yum -y update

# スクリプトを入手するためのgitをインストール
[vagrant@localhost ~]$ sudo yum -y install git

# gitを使ってアプリケーション設定用のスクリプトをダウンロード
[vagrant@localhost ~]$ git clone https://github.com/dotinstallres/centos6.git

# centos6フォルダができるのでそちらに移動
[vagrant@localhost ~]$  cd centos6

# スクリプトを実行(時間かかります)
[vagrant@localhost ~]$  ./run.sh

# もろもろの設定を反映
[vagrant@localhost ~]$  exec $SHELL -l

ファイル転送ツール

仮想マシン上のファイルを簡単に扱えるようにするファイル転送ツールを導入する。
今回はCyberduckを使う
https://cyberduck.io/index.ja.html?l=ja

仮想マシンを止める

仮想マシンを抜ける
[vagrant@localhost ~]$ exit

 #仮想マシンを止める(時間がかかるときがある) 
 $ vagrant suspend 
0
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
0
1