How to access from the host the Apache virtual domain created on virtual machine.
Settings of the VM on VirtualBox:
- VM ubuntu/precise32 on VirtualBox created with vagrantfile from How to setup a LAMP development environment in Vagrant by Sanchit Jain Rasiya
- installed Apache/2.2.22
- installed Lynx browser
Virtual Host /etc/apache2/sites-available/example.com
ServerAdmin webmaster@example.com ServerName example.com DocumentRoot /home/vagrant/www/example.com AllowOverride All Order allow,deny Allow from all ErrorLog "/home/vagrant/www/example.com/logs/example.com-error.log" CustomLog "/home/vagrant/www/example.com/logs/example.com-access.log" combined
From the browser on the host machine I can access VM's localhost
as http://192.168.205.10/index.html
How can I access VM's example.com?
On the host's /etc/hosts
I have added line for example.com
127.0.0.1 localhost
127.0.0.2 tmp.loc
127.0.0.3 temp.loc
192.168.205.10 example.com
When I try http://example.com/mj.html
I get the 404 Not Found
page from Apache/2.2.22 (Ubuntu) Server at example.com Port 80
On the virtual machine I can access page with the Lynx
lynx http://example.com/mj.html
This is noted in the /home/vagrant/www/example.com/logs/example.com-access.log
file as
127.0.0.1 - - [03/Apr/2016:15:53:49 +0000] "GET /mj.html HTTP/1.0" 200 344 "-" "Lynx/2.8.8dev.9 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.12.14"
But when I try to access example.com from the host there are no logs neither in access.log nor /home/vagrant/www/example.com/logs/example.com-error.log
There are no logs in the host's Server files /opt/lampp/logs/access_log and /opt/lampp/logs/error_log