Apache Web Server on a VirtualBox Windows 7 Guest OS

Here’s a guide to getting a Windows, Apache, MySQL, and PHP (WAMP) stack up and accessible via the internet on a virtualized Windows 7 environment. These instructions are specific to the VirtualBox virtualization program on OSX.

Network Connection
You’ll need to go to the Network settings for the virtual machine. Make sure that you’re using the Bridged Adapter option set to the Wi-fi mode or Ethernet depending on how you’re machine is connected to the router. If you’re directly connected via an ethernet cable, then select Ethernet, otherwise, go with Wi-Fi. See the picture below for clarification.

VirtualBox Network Settings
VirtualBox Network Settings for Win 7 Guest OS

After you change these settings and hit OK, the connection on your virtual machine (VM) will reset. Give it a couple of minutes and you’ll have restored access to the internet.

Find Your Local IP
You’ll need to know the IP address of your VM. Since you changed the network settings, your VM will actually have its own IP address given by the router’s DHCP protocol.

There are two solutions to finding your VM’s IP address:

Go into the command prompt and issue the command:
ipconfig -all

You’ll see something like:
IPv4 Address. . . . . . . . . . . : 192.168.1.102

The other way is to login to your router via accessing 192.168.1.1 in a web browser. Once you supply your credentials, you should be able to find a way to view all of the connected clients to your local network. The location of that feature depends on the router you’re using — different brands have different router configuration pages.

Keep your router configuration page open for the next step!

Port Forwarding
You’ll need to set up port forwarding so that HTTP requests get forwarded to your VM’s IP address. Again, the specific menu navigation differs based on the router’s brand. In any case, you should be able to set up HTTP requests on port 80 to get forwarded to your VM’s address (192.168.1.102 in my example).

While you’re there, you might want to forward FTP requests to your VM as well. This way, you can FTP into the server via the web and modify whatever you need to. I recommend FileZilla Server; it’s easy to set up.

Windows Firewall
This last step is precautionary. You’ll need to configure Windows Firewall to allow public access to your Apache web server.

You can go to Control Panel -> Windows Firewall. In the firewall dialog box, go to Allow a Program or Feature through Windows Firewall (it’s a link on the left side column).

You’ll want to check both the Private and Public options to give local and remote access to your web server. See the image below for clarification.

Allow Apache in Windows Firewall
Allow Apache in Windows Firewall

Finishing Up
You’ll need to know your global IP address (not a local 192.168… one). You can visit WhatIsMyIP to get your IP address.

Once you have your address, you can visit your IP address in your web browser. This should route that web request (on port 80) to your VM’s Apache web server and load up whatever is in your “www” directory in your WAMP installation path.

Hope it helps!