First published: 13 Nov 2016
Last updated: 13 Nov 2016
Note: Most of these notes apply for all Linux distros but some might be Debian specific.
The virtual machine should be configured with two network interfaces, one as NAT to allow access to the Internet from within the guest operating system (OS) using the host Internet connection and the other as a Host-only Adapter to create a host/guest internal network over which you can test access to the websites and applications hosted on Apache. In this example, the IP of the virtual machine on the host-only adapter is going to be 10.10.4.2 and the IP of the host will be 10.10.4.1.
On the virtual machine, edit
/etc/hosts to set up the IP for the virtual sites, so that you can test them from within a web browser from the virtual machine OS. For example, it should look like so:
127.0.0.1 localhost 127.0.1.1 debian-laptop.local debian-laptop # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters #virtualhosts 10.10.4.2 testdomain.com 10.10.4.2 testdomain2.com
To access and test the websites from the host OS you need to update the hosts file of the host OS. If the host OS is Microsoft Windows the hosts file can be found in
If you are using your virtual machine in one place, say at work, and then suspend and resume work at home or someplace else, you might find that the virtual machine cannot connect to the Internet. This happens because the network interface of the virtual machine using NAT is still looking for the physical network at your previous location that is no longer available. To get it working again, you need to reset the virtual machine network interface to connect through the new physical network present in your new location, as shown below.
sudo ifdown eth0 sudo ifup eth0
Follow these steps to install the Guest Additions on your Debian virtual machine:
apt-get install build-essential module-assistant
sh /media/cdrom/VBoxLinuxAdditions.run, and follow the instructions on screen.
First install the VirtualBox guest additions on the virtual machine to enable shared folder support amongst other features.
Then use VirtualBox to set up a shared folder, giving it a name, say,
Finally, edit the
/etc/rc.local to automatically mount the shared folder at boot up time by adding an entry such as
mount -t vboxsf share /home/user/host, where
share is the name you gave to the shared folder and
/home/user/host is the location where you want to mount this shared folder on the guest machine.
sudo apt-get install ntp.
sudo nano /etc/ntp.conf
tinker panic 0so that NTP will ignore large differences in time between guest and host, and sync appropriately when the virtual machine is resumed. These time differences occur when a virtual machine is paused and resumed hours or days later.
If the above steps still do not help, after resuming the virtual machine you could run
sudo service ntp restart.