Vagrant(CentOS)でwebサーバを起動し、ホストOSのブラウザから確認したい
環境
- ホストOS: MacOS Sierra
- ゲストOS: CentOS7.0
- httpd(2.4)でwebサーバを起動
firewallでhttpは許可しました。SELinuxもdisabledにしました。
以下、Vagrantfileの記述です。
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure(2) do |config| config.vm.box = "CentOS7.0" config.vm.network "private_network", ip: "192.168.33.33" config.vm.hostname = "centos" config.vm.synced_folder "www", "/var/www/html", :mount_options => ["dmode=777", "fmode=666"] end
ホストOSでのifconfigの結果です。
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201<PERFORMNUD,DAD> gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 98:01:a7:97:56:b7 inet6 fe80::10f6:1ba2:fa9b:e81e%en0 prefixlen 64 secured scopeid 0x4 inet 192.168.55.12 netmask 0xffffff00 broadcast 192.168.55.255 nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active en1: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500 options=60<TSO4,TSO6> ether 6a:00:02:3e:82:50 media: autoselect <full-duplex> status: inactive en2: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500 options=60<TSO4,TSO6> ether 6a:00:02:3e:82:51 media: autoselect <full-duplex> status: inactive bridge0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500 options=63<RXCSUM,TXCSUM,TSO4,TSO6> ether 6a:00:02:3e:82:50 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x2 member: en1 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 5 priority 0 path cost 0 member: en2 flags=3<LEARNING,DISCOVER> ifmaxaddr 0 port 6 priority 0 path cost 0 nd6 options=201<PERFORMNUD,DAD> media: <unknown type> status: inactive p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 ether 0a:01:a7:97:56:b7 media: autoselect status: inactive awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 ether 92:aa:6e:bf:bf:bd inet6 fe80::90aa:6eff:febf:bfbd%awdl0 prefixlen 64 scopeid 0x9 nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 0a:00:27:00:00:00 inet 192.168.33.1 netmask 0xffffff00 broadcast 192.168.33.255 vboxnet2: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 0a:00:27:00:00:02 utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 inet6 fe80::c021:b4ab:ee97:dd22%utun0 prefixlen 64 scopeid 0xa nd6 options=201<PERFORMNUD,DAD>
vagrant up した際に以下のようなエラーメッセージが出ます
==> default: Configuring and enabling network interfaces... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! # Down the interface before munging the config file. This might # fail if the interface is not actually set up yet so ignore # errors. /sbin/ifdown 'enp0s8' # Move new config into place mv -f '/tmp/vagrant-network-entry-enp0s8-1488473945-0' '/etc/sysconfig/network-scripts/ifcfg-enp0s8' # attempt to force network manager to reload configurations nmcli c reload || true # Restart network service network restart Stdout from the command: Restarting network (via systemctl): [FEHLGESCHLAGEN] Stderr from the command: Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn' for details.
一応、vagrant sshでvagrantの中に入ることはできます。
ゲストOS上でのifconfigの結果です。
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::a00:27ff:fede:e0e prefixlen 64 scopeid 0x20<link> ether 08:00:27:de:0e:0e txqueuelen 1000 (Ethernet) RX packets 506 bytes 56974 (55.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 326 bytes 49487 (48.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.33.33 netmask 255.255.255.0 broadcast 192.168.33.255 inet6 fe80::a00:27ff:fe77:af5e prefixlen 64 scopeid 0x20<link> ether 08:00:27:77:af:5e txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 21 bytes 1586 (1.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
色々と試したりググったりしましたが解決方法がわかりません。。。
どうすればいいのでしょうか、、、、
追記
Vagrantfileにconfig.vm.network "forwarded_port", guest: 80, host: 8000
を追記したらブラウザから確認することができました。しかし、起動時のエラーが消えないのと、共有フォルダの設定がうまく行きません。以下、エラー内容です。
==> default: Configuring and enabling network interfaces... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! # Down the interface before munging the config file. This might # fail if the interface is not actually set up yet so ignore # errors. /sbin/ifdown 'enp0s8' # Move new config into place mv -f '/tmp/vagrant-network-entry-enp0s8-1488537141-0' '/etc/sysconfig/network-scripts/ifcfg-enp0s8' # attempt to force network manager to reload configurations nmcli c reload || true # Restart network service network restart Stdout from the command: Restarting network (via systemctl): [FEHLGESCHLAGEN] Stderr from the command: Job for network.service failed. See 'systemctl status network.service' and 'journalctl -xn' for details.
何が原因でこんなことが起こっているのでしょうか、、、
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/03 10:29
2017/03/29 00:00