Consolidate: Put Your Servers into a VirtualBox VM
Sep 30, 2010 By Michael Reed
Rather than installing a server, such as a web server, directly onto your main computer, why not install it in a VM? This sort of setup has a few advantages of security and convenience. These days, spreading resources out into the cloud is the in-thing, but consolidation is often underexploited. Hosting a server in a virtualizer such as VirtualBox is often a good approach for casual or occasional server needs on a home network. This is an outline of a setup that makes use of Debian, running Apache, installed onto a VirtualBox VM. If you would like to install a different type of server, but you haven't done this sort of job before, it might be a good idea to follow through with the Apache example as it is a simple way of testing the networking side of things. As I said, consolidation is underrated concept these days. Often, when people talk about keeping an old machine up and running, in a cupboard, just to run a web server, I wonder if their main machine has CPU cycles, memory, storage or even whole CPU cores going spare. Unless your needs are great, it's doubtful that an external source could provide resources more efficiently than a little extra load on your main box. Why put the server in a VM? Obviously, some server tasks are mission critical and need a dedicated machine for greater reliability, but if you have only a casual or occasional need to employ a server, ask yourself how often your desktop machine totally falls over. Modern operating systems have reached the point where if my main box completely locked up I'd suspect a hardware fault. Of course, you could always install the server directly onto your main desktop, but that can bring its own problems. Package management makes it easy to add and remove server software, but as often as not, you end up having to make some small changes to your machine to accommodate a server. Also, if your locally hosted server is exploited in some way, it could bring your main computer into the line of fire. Another advantage of keeping your server locked up inside a VM is that it makes the server environment portable. It's easy to copy a hard disk image and import it into VirtualBox. This means that your servers don't need to be set up and configured from scratch when you move over to a new machine. Virtualizers also allow you to shut down or pause your server environment or snapshot a working setup that can be reverted to in the event of a mishap.
su root [enter password] ifconfigOn a fairly fresh install, details for two network interfaces, eth0 and lo, should be listed. To ensure that the VM can communicate with the outside world, the second line of the eth0 description should start with something something like:
inet addr:192.168.1.12If the VM hasn't been assigned an IP address at all by your router, look up the instructions to assign a static address for your choice of guest operating system (Debian instructions here, for example). Once that’s working, the hard part is over. Next install Apache in the normal way:
su root apt-get install apache2Apache pretty much sets itself up, these days. First, test that it is running and can be accessed from other machines on the network such as your host machine. Point the browser to the IP address that you obtained from running ifconfig on the guest VM. Hopefully, this will display the “It works!” message from Apache. VirtualBox hosting a Debian guest. The install is slimline as I opted not to bother with a graphical environment. Firefox successfully finds the Apache install. I asked an IRC buddy to make sure that it could be seen from the Internet. Next, setup port forwarding for your router so that machines on the Internet can reach your server VM. If you don't know how to do this, consult the instructions for your router. Specifically, you need to forward external requests to port 80 to port 80 on the IP address assigned to the VM. The VirtualBox website.
UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.
- diff -u: What's New in Kernel Development
- Divx# Watch The Other Woman Full HD Online Streaming Viooz
- Numerical Python
- Use Linux as a SAN Provider
- Great Scott! It's Version 13!
- NSA: Linux Journal is an "extremist forum" and its readers get flagged for extra surveillance
- Tech Tip: Really Simple HTTP Server with Python
- RSS Feeds
- Adminer—Better Than Awesome!
- Linux Systems Administrator