title: VirtualBox: How to access virtual host on VM from host?
body: <p>How to access from the host the Apache virtual domain created on virtual machine.</p>
  
  <p>Settings of the VM on VirtualBox:</p>
  
  <ul>
  <li>VM ubuntu/precise32 on VirtualBox created with vagrantfile from <a href="https://www.howtoforge.com/tutorial/vagrant-ubuntu-linux-apache-mysql-php-lamp/" rel="nofollow">How to setup a LAMP development environment in Vagrant by Sanchit Jain Rasiya</a></li>
  <li>installed Apache/2.2.22 </li>
  <li>installed Lynx browser</li>
  <li><p>Virtual Host  /etc/apache2/sites-available/example.com</p>
  
  <p>
      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
  </p></li>
  </ul>
  
  <p>From the browser on the host machine I can access VM's <code>localhost</code> as <code>http://192.168.205.10/index.html</code>
  How can I access VM's example.com?</p>
  
  <p>On the host's <code>/etc/hosts</code> I have added line for example.com</p>
  
  <pre><code>127.0.0.1   localhost
  127.0.0.2   tmp.loc
  127.0.0.3   temp.loc
  192.168.205.10  example.com
  </code></pre>
  
  <p>When I try <code>http://example.com/mj.html</code> I get the <code>404 Not Found</code> page from <em>Apache/2.2.22 (Ubuntu) Server at example.com Port 80</em></p>
  
  <p>On the virtual machine I can access  page with the Lynx </p>
  
  <pre><code>lynx http://example.com/mj.html
  </code></pre>
  
  <p>This is noted in the <code>/home/vagrant/www/example.com/logs/example.com-access.log</code> file as </p>
  
  <pre><code>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"
  </code></pre>
  
  <p>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</p>
  
  <p>There are no logs in the host's Server files /opt/lampp/logs/access_log and /opt/lampp/logs/error_log </p>