5
6

More than 5 years have passed since last update.

Win8上でVagrant動かしてCentOS7セットアップ

Last updated at Posted at 2015-03-05

VMWarePlayerでやるよりVagrantでやるのがいいと知ってしまったのでVMを捨ててVagrant upすることにしました。

vagrantのインストール

Virtual Boxのインストール

ついでにCygwinもインストール

少し脱線してCygwinもセットアップしました

  • デフォルトインストール
  • 環境変数HOMEにC:\users\みたいな感じでいれる

vagrant box add centos

ここ( http://www.vagrantbox.es/ )のCentOS7ミニマルを持ってきました。

$ vagrant box add centos https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box
$ vagrant init centos
$ vagrant up


 
sshを127.0.0.1:2222に試みる。

  • ユーザ名:vagrant
  • 認証をRSAにして.vagrant/の下のほうにある秘密鍵で接続してつながるのを確認

yumとかでいろいろ入れる

以前やったこれを元にして実行。

飛ばした手順

  • sudo使えるユーザの追加
  • sudo yum groupinstall "Development tools"(何故か失敗した)

nodeを動かす

hello.js

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

というファイルを作って下記コマンドしてから

$ sudo systemctl stop firewalld
$ node hello.js

http://127.0.0.1:8124/hello.js
にアクセス

・・・すると繋がらない

ネットワークの設定を変更する

Vagrantfile

# config.vm.network "public_network"

この行のコメントを外し、

$ vagrant reload

で再起動。

そしたらCentOS上でip show addrして、LAN上のIPアドレスが割り振られていることを確認
問題なければ、再度ファイヤーウォール切ってnode hello.jsしてhttp://192.168.1.3:8124/hello.js
にアクセス

 
bab59cd9e0fea9c09a36ceff426f4a81.png

お疲れ様でした。

参考にしたサイト

【導入編】Vagrantでローカルサーバー環境を作ろう。for 64bit版Windows8.1
http://cityjumperweb.com/2014/10/11/vagrant%E2%80%90windows8-1-2/

Vagrantをブリッジ接続する
http://www.h-fj.com/blog/archives/2013/10/31-103556.php

5
6
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
5
6