Accessing an Apache server installed in VirtualBox from Mac

Solution 1:

  • Set up Host-Only, Internal or Bridged Networking. Whenever you change the virtual machine's network configuration you need to inform the operating system within that virtual machine of that change. The easiest way is to simply reboot the virtual machine.
  • Look up the virtual machine's IP-Adress using ip addr eth0.
  • Verify basic connectivity using ping <ip-address from previous step> from your mac's terminal.
  • Edit your mac's /etc/hosts using sudo vim /etc/hosts (or use an editor like text mate that can elevate privileges by itself). Add a line that looks like this: <ip-address as above> myvirtualbox anothername yetanothername

A more powerful approach, albeit maybe only for a more console-savvy audience is Vagrant.