Ubuntu Server 16.04.1 Xenial Xerus(32ビット)をWindows 7ホストのVagrantを使用してVirtualboxにインストールしました。Vagrantfileの内容は
Vagrant.configure("2") do |config|
config.vm.box = "boxcutter/ubuntu1604-i386"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.hostname = "vagrant.templavoilaplus"
config.vm.network "private_network", ip: "192.168.33.148"
config.vm.synced_folder "E:/xampp/htdocs/github/templavoilaplus/", "/var/www/templavoilaplus/public_html"
config.vm.provision "shell", path: "setup_for_ubuntu_box.sh"
end
実行中のvagrant upの表示は
E:\Virtual Machines\vagrant>vagrant up
==> default: Checking if box 'boxcutter/ubuntu1604-i386' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 (guest) => 8080 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
==> default: Machine booted and ready!
[default] GuestAdditions seems to be installed (5.1.22) correctly, but not
runni
ng.
: Inappropriate ioctl for device
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => E:/Virtual Machines/vagrant
default: /var/www/templavoilaplus/public_html =>
E:/xampp/htdocs/github/templavoilaplus
==> default: Machine already provisioned. Run `vagrant provision` or use the
`--
provision`
==> default: flag to force provisioning. Provisioners marked to run always will
still run.
E:\Virtual Machines\vagrant>
Windowsホストファイルの内容は次のとおりです。
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
216.98.48.18 127.0.0.1
216.98.48.53 127.0.0.1
216.98.48.57 127.0.0.1
216.98.48.133 127.0.0.1
216.98.48.134 127.0.0.1
#adaugat 28/5/2017 pentru vhost xampp github
127.0.0.1 localhost
127.0.0.1 github.localhost
#adaugat 2/6/2017 pentru vagrant private network
192.168.33.148 vagrant.templavoilaplus
仮想マシンでは、apache2およびphpモジュール(シェルスクリプトによる)を提供し、000-default.confをtemplavoilaplus.confにコピーおよび変更して仮想ホストを作成しました。ファイルの内容は
<VirtualHost *:80>
ServerAdmin alex@google.com
ServerName vagrant.templavoilaplus
DocumentRoot /var/www/templavoilaplus/public_html
ErrorLog ${APACHE_LOG_DIR}/templavoilaplus_error.log
CustomLog ${APACHE_LOG_DIR}/templavoilaplus_access.log combined
</VirtualHost>
public_htmlフォルダーには、ホストからのフォルダーがマウントされます。その後、a2ensiteを実行し、Apacheをリロードしました。/ etc / hostの内容は次のとおりです。
127.0.0.1 vagrant
127.0.0.1 localhost
127.0.0.1 vagrant
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
##vagrant-hostmanager-start
192.168.33.148 vagrant.templavoilaplus
##vagrant-hostmanager-end
ホストでブラウザーを開いて192.168.33.148と入力すると、Apache2 Ubuntuのデフォルトページが表示されます(成功です)。また、ホストでpingを実行すると
ping vagrant.templavoilaplus
結果は
Ping statistics for 192.168.33.148:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
ゲストでpingを実行した場合(パテによる)
ping vagrant.templavoilaplus
似たようなもの(192.168.33.148)が表示されます。
問題はこれです:ホストのブラウザのアドレスバーに入力すると
vagrant.templavoilaplus
空白のページ(mozilla)またはGoogle検索結果(chrome)が表示されます。ページindex.php(仮想ホストのリダイレクト後)に「成功」が表示されます。