Я установил Ubuntu Server 16.04.1 Xenial Xerus (32-разрядная версия) в Virtualbox с Vagrant на хосте Windows 7. Содержимое 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
Когда в бегущем бродит вверх, дисплей
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 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 vagrant.templavoilaplus
он отображает нечто подобное (192.168.33.148).
Проблема заключается в следующем: если я наберу в адресной строке браузера хоста
vagrant.templavoilaplus
Я получаю пустую страницу (Mozilla) или результаты поиска Google (Chrome). Страница index.php (после перенаправления виртуального хоста) должна отображать "успех".