Setup guide for running a lightweight headless[1] web server virtual machine guest on an OS X machine host. The VM will be an SSH host, ideal for Python web development. I’ll primarily be developing on Django, and the webserver stack setup will be in a follow-up post.
This guide was built with the following platforms, YMMV.
You’ll need an active internet connection to use the netinst image, VirtualBox provides a pretty solid, generic virtual LAN device[2] so you shouldn’t need any extra drivers.
VirtualBox Setup
If you don’t have VirtualBox already installed, it’s a pretty straightforward setup. Just follow the install wizard after opening the disk image.
- Once VirtualBox is installed, run it and select “New” from the VM Manager screen.
- Click continue on the first dialog
- Give your VM a name, if you label it with Debian the OS and Version should pre-fill for you. Click continue.

- Select a memory value in MB, I’ve used 1024MB to make the install a breeze but day-to-day usage I think 384MB as recommended will be more than sufficient for a headless install. You can modify this value any time the machine is not running. Click continue.

- Create a new or use an existing virtual disk. Click continue.

- Just hit continue on the next screen unless you need interoperability between VM Managers.
- Read the info on each disk allocation, but I find dynamic to be suitable for most uses. Click continue.
- Select a maximum disk size value, I’ve gone with 4GB which should be sufficient (I’m on an SSD so space is at a premium).

- If you’re happy with the Summary of the virtual disk then click Create.
- Same again for the VM. Click Create if it all checks out.

VM Config
Before you start it’s easiest if you load the Debian ISO now. Open the Settings dialog for the VM you just added.
- Open the Storage tab
- In the Storage Tree pane select the Empty medium underneath the IDE Controller, this is your virtual CD/DVD drive

- In the right pane click on the CD icon to the right of the bus selector

- Click OK to save the config
- Ready to launch!

Debian Install
Fire up the VM and wait for it to load the ISO. The installation process is guided and quite straightforward, however it doesn’t hurt to have the installation documentation handy.
Once you reach the Software Selection step of the installation you may wish to change the defaults. I selected Mail server, SSH server and Standard system utilities only.
System Configuration
The next steps are personal preference, but keep in mind further setup will rely on some of them so it’s worth a scan.
I’ve chosen to install sudo before I proceed with setup.
~$ su -
Password:
root$ apt-get update
... [ packages will be updated from your apt mirrors]
root$ apt-get install sudo
You’ll either want to add your regular user explicitly to the sudoers with the visudo command or add required users to the sudo group. I like to explicitly add my user to the sudoers
root$ export EDITOR=vi
root$ visudo
... add user to sudoers ...
:wq
root$ exit
Note: If you’re going to be using this VM as an SSH host you’ll note that when executing sudo ifconfig that your eth0 inteerface has a private IP address as it acts as a bypass to your internet connection. You’ll want to add a new virtual ethernet adapter, or, if you don’t need internet access once the VM is configured just update its settings.
- ACPI Shutdown the VM (Cmd/$Host + U)
- Open the VM Manager Preferences
- Switch to the Network tab
- Click add (top button on the right of the list)
- Save/close the preferences[3]
- Open the Settings pane for your VM, open the Network tab
- Add a new Network Adapter by clicking on the Adapter 2 pill tab
- Make it a host-only adapter, with name set to the
vboxnet0 virtual adapter we just added
Fire up the VM again and edit the /etc/network/interfaces file:
~$ sudo vi /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
# Host-only network interface
auto eth1
iface eth1 inet static
address 192.168.56.2
netmask 255.255.255.0
You should now be able to ssh to your virtual host from your local machine:
~$ sudo echo 192.168.56.2 devserv >> /etc/hosts
~$ ssh devserv
If everything checks out there, Shutdown the VM (Cmd/$Host + U). Time to run the Virtual Machine headlessly:
~$ VBoxHeadless -s "Debian Webserver"
OR
~$ nohup VBoxHeadless -s "Debian Webserver" > nohup_vm.txt &
You can see in the VM Manager the preview of the running VM so you should be able to tell when it’s at the login prompt, you should be able to connect to the ssh server by that point.
To power off the machine gracefully:
local$ VBoxManage controlvm "Debian Webserver" acpipowerbutton
Annotations
- Both because we’re not running an X server, and VirtualBox has a headless mode
- To access the host on your own LAN you will need to see the notes on adding a second adapter.
- You can change the IP address and other settings, but I encountered issues when doing so. VirtualBox has its own private IP range configured already so it’s probably easiest just to use that.