vagrant+Ruby on rails環境でブラウザからアクセスする
これすっごくハマりました^^;
ググっていろいろ探してみたらこちらのサイトが!!
Vagrant で Ruby on Rails 4 の環境構築 - Qiita
こちらを参考にやってみる。
(1)Vagrantfile修正
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3000, host: 3000
⇒Railsで使用するポートをフォワードさせてあげる設定を追加
(2)Vagrant再起動
> vagrant reload
(3)Railsを起動
# rails server -b 0.0.0.0
=> Booting WEBrick
=> Rails 4.2.6 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-04-17 07:10:40] INFO WEBrick 1.3.1
[2016-04-17 07:10:40] INFO ruby 2.3.0 (2015-12-25) [x86_64-linux]
[2016-04-17 07:10:40] INFO WEBrick::HTTPServer#start: pid=2436 port=3000
⇒ここがポイントです!!
どうやら 、Rails 4.2からデフォルトのホストが0.0.0.0からlocalhostに変更されたみたいです。
(4)ブラウザでhttp://localhost:3000にアクセス
⇒うまくいきました!!!
マニュアルをちゃんと読めってことですね。。。。。^^;