Reputation: 31
How to access from the host the Apache virtual domain created on virtual machine.
Settings of the VM on VirtualBox:
Virtual Host /etc/apache2/sites-available/example.com
ServerAdmin [email protected] 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
Upvotes: 2
Views: 4030
Reputation: 306
On Ubuntu /etc/hosts:
127.0.0.1 localhost
127.0.2.2 example.com
On Windows (VBox) C:\Windows\System32\drivers\etc\hosts:
10.0.2.2 localhost
10.0.2.2 example.com
Then just reboot your VBox Windows and type in browser (on Windows): http://example.com/
Upvotes: 1
Reputation: 49
I have the same issue, I've been trying to access my drupal project from my virtualbox vm but it is not working. One of the solutions I found on the Internet is using the outer keyword in your hosts file in the VM.
The following works fine for me:
Add this address to the host file in your virtualobox machine and use the outer keyword
[192.168.1.15 outer]
Now you can access your localhost from your virtualbox browser by typing the address of your wlan0 (ex: 192.168.1.15).
Upvotes: 0