記録 開発

開発環境 Vagrant/VirtualBox

更新日:

Windows10にVagrant+VirtualBoxで開発環境を構築する。

VirtualBoxは仮想化ソフト。

Vagrantは仮想化ソフトを操作して仮想マシンを管理するためのコマンドツール。


以下からVagrantとVirtualBoxをダウンロードしてインストール

Vagrant
https://www.vagrantup.com/downloads.html

VirtualBox
https://www.virtualbox.org/wiki/Downloads

下記でインストールするBoxファイルを検索
https://app.vagrantup.com/boxes/search

今回は "bento/centos-7.6" を使います。


フォルダの作成
> mkdir c:\users\public\vagrant\centos76

フォルダへ移動
> cd c:\users\public\vagrant\centos76


Vagrantfileを作成して、新しいVagrant環境を初期化
> vagrant init bento/centos-7.6

Vagrantfileをテキストエディタで編集

Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-7.6"
end

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

仮想マシンの起動
> vagrant up
初回は構築処理が走るのですごい時間がかかる
私の環境では2時間ぐらいかかった
(別の環境で行ったら10分もかからなかったネットワークの調子が悪かったのか)

デフォルトでsshが使えるようになっていて、以下のユーザーが登録されている
ユーザー/パスワード
vagrant/vagrant
root/vagrant

仮想マシンへの接続
> ssh vagrant@192.168.33.10

仮想マシンの停止
> vagrant halt

-記録, 開発
-, ,

Copyright© indite , 2025 All Rights Reserved Powered by STINGER.