3
3

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 5 years have passed since last update.

Vagrant memo

Last updated at Posted at 2014-10-25

参考サイト
http://easyramble.com/install-vagrant-virtualbox-on-mac.html

command topic
vagrant up VMを起動
vagrant ssh ssh接続
vagrant status 状態を確認
vagrant suspend 一時停止
vagrant reload リロード
vagrant halt 仮想マシンを停止
vagrant destroy 仮想マシンを削除

Vagrant のインストール

インストール後、バージョン確認

$ vagrant --version
Vagrant 1.6.3

VMの構築ベースのBOXを追加

下記URLよりダウンロードする
http://www.vagrantbox.es/

CentOS 6.5
https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box

vagrant box add centos65 https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box

インストール終了後、確認

$ vagrant box list
centos65 (virtualbox, 0)

~/Vagrant/CentOS65 ディレクトリで作業します。

$ mkdir -p ~/Vagrant/CentOS65
$ cd ~/Vagrant/CentOS65
$ vagrant init centos65
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ ls
Vagrantfile

vagrant ssh

下記でSSH接続ができる

$ cd ~/Vagrant/CentOS65
$ vagrant ssh

Vagrantユーザーはパスワード無しで sudo できる。
rootパスワードは「vagrant」

Vagrantfile の設定

$ vi Vagrantfile

config.vm.network "private_network", guest: 80, host: 8080

ポートフォワーディングの設定。
上記例の場合、80番ポートなのでゲストOSのウェブサーバーにアクセスできる。

config.vm.network "private_network", ip: "192.168.33.10"

プライベートネットワークの設定。

config.vm.synced_folder "/host/path", "/guest/path"

ゲストとホストでフォルダを共有させる。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?