LoginSignup
0
0

More than 3 years have passed since last update.

Vagrant学習メモ

Last updated at Posted at 2019-09-12

Vagrantとは

こちらの方の記事が参考になると思います。

【決定版】仮想環境ってなに?Vagrantってなんなの?に答える!

Vagrantコマンド(ファイル作成から仮想マシン起動、停止まで)

# ホームディレクトリに移動
$ cd

# 今後複数の仮想マシンを作ることを想定して、それらをまとめるフォルダ(MyVagrant)を作る
$ mkdir MyVagrant

# MyVagrantに移動する
$ cd MyVagrant

# 仮想マシンを作るフォルダを作る(MyCentOS)
$ mkdir MyCentOS

# MyCentOSに移動する
$ cd MyCentOS

# 仮想マシン設定用のVagrantfileを作る
$ vagrant init bento/centos-6.8

# Vagrantfileを編集して仮想マシンのIPアドレスを192.168.33.10にする
$ sed -i '' -e 's/# config.vm.network "private_network", ip: "192.168.33.10"/config.vm.network "private_network", ip: "192.168.33.10"/' Vagrantfile

# 仮想マシンを起動する(少し時間かかります)
$ vagrant up

# 仮想マシンの状態を確認する
$ vagrant status

# 立ち上げたサーバーにログインする
$ vagrant ssh

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

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

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

# centos6フォルダができるのでそちらに移動
$ cd centos6

# スクリプトを実行(時間かかります)
$ ./run.sh

# もろもろの設定を反映
$ exec $SHELL -l

# 仮想マシン停止
$ vagrant suspend 

参考資料

ドットインストール ローカル環境の構築(MacOS編)

0
0
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
0