Run Apache in VirtualBox

February 20, 2012
linux command-line open-source virtualbox virtualization virtual-machines

VirtualBox is a great tool when it comes to experiment things with your OS. I’ve been using it for a long time to try & test distros showing up on distrowatch.com.

Recently, I wanted to set up a virtual lab to contain a development LAMP server. I got all applications & tools running inside my Mint box. Now, what remained was to view the pages from the host. I did some googling and it didn’t take much time getting it down.

Oracle VirtualBox

VirtualBox comes bundled with a nice utility called ‘vboxmanage’. Vboxmanage supports everything (or a little more) than what the graphical user interface allows you to do with the click of a button. Vboxmanage is used with specific subcommands like createvm, startvm, registervm etc. For a full list of these subcommands type ‘vboxmanage –help’.

If you have already set up your Guest VM, you can register it through vboxmanage as follows:

vboxmanage registervm GuestName /path/to/guestfile

The guestfile is actually the VirtualBox configuration file of that specific VM. It is usually stored within ‘/home/username/Virtual Box VMs/GuestName’. The file name should be like filename.vbox-prev. The config is stored in XML format.

Once the VM has been registered, you can set up port forwarding as follows:

vboxmanage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" 8888

vboxmanage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" 80

vboxmanage setextradata GuestName "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" TCP

Restart the virtual machine with the following command:

vboxmanage startvm GuestName

You can do the same for the SSH port.

City Council of Barcelona switches from Microsoft Windows to Linux

February 11, 2018
linux ubuntu microsoft open source data protection

linux.com website compromised?

December 7, 2017
linux wordpress security

Linux Magazine's special edition on openSUSE

November 20, 2017
opensuse linux university-of-mauritius education