Vous êtes sur la page 1sur 5

10/13/2014 Consolidate: Put Your Servers into a VirtualBox VM | Linux Journal

Consolidate: Put Your Servers into a VirtualBox VM


Sep 30, 2010 By Michael Reed (/users/michael-reed)
in

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 (www.apache.org/) , installed onto a VirtualBox (http://www.virtualbox.org/) 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. Setting it up Installing a server such
as Apache in a VirtualBox VM doesn't differ
greatly from installing it natively. Begin with a
suitable Linux installation. It might be a good
idea to choose something a bit lighter than a
mainstream desktop distribution in order to
conserve resources on the host machine. Debian
with a lightweight window manager could be a
good start (see my guide
(http://www.linuxjournal.com/content/slimline-debian-
install-its-easier-you-might-think) ).
If you're familiar with the command line interface for
the server that you want to deploy, an install without a graphical environment can be
ideal. The important VirtualBox networking setting that you have to select is
bridged rather than the default of NAT. By default, VirtualBox VMs present the
guest operating system with a networking setup that works well enough for a web
browser, or similar, to connect to the outside world. Selecting bridged networking
makes the VM appear as though it is simply another computer attached to your
network via an Ethernet cable. One consequence of using bridged networking is that
your network will have to supply the VM with an IP address. If your router has DHCP
enabled, it should set the VM up in the same way that it would any other computer
on the network. To check to see if the VM has an IP address, make yourself root and
type: su root [enter password] ifconfig On 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.12 If the VM hasn't been
assigned an IP address at all by your router, look up the instructions to assign a static

http://www.linuxjournal.com/content/consolate-put-your-servers-virtualbox-vm 1/5
10/13/2014 Consolidate: Put Your Servers into a VirtualBox VM | Linux Journal
address for your choice of guest operating system (Debian instructions here
(http://www.debian-administration.org/articles/254) , for example). Once thats working, the
hard part is over. Next install Apache in the normal way: su root apt-get install
apache2 Apache 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 (http://www.virtualbox.org/) website.

______________________

UK based freelance writer Michael Reed (http://www.unmusic.co.uk/) writes about


technology, retro computing, geek culture and gender politics.

Comments

Comment viewing options


Threaded list - expanded Date - newest first 50 comments per page Save settings
Select your preferred way to display the comments and click "Save settings" to activate your changes.

Criticism (/content/consolate-put-your-servers-virtualbox-vm#comment-356767)
Submitted by Sunny Bharel (Open Source Proponent) (not verified) on Sun, 10/10/2010 -
17:53.

Few comments on your effort:

1. A main machine MAY have extra CPU cores and cycles to take on the load of an
additional Apache server. However, the virtual machine itself saps up huge amounts of system memory and
processing power. Let us not forget.

2. If the main box has a hardware failure, all VMs running on it go down as well.

http://www.linuxjournal.com/content/consolate-put-your-servers-virtualbox-vm 2/5
10/13/2014 Consolidate: Put Your Servers into a VirtualBox VM | Linux Journal
In other words, dependency is not a wise step. Servers, wherever possible must be separate physical
entities. VM machines are best used for testing environments to save costs. They are not an alternative to
real world server solutions especially ones offering support to mission critical applications or ones with high
availability and high load requirements.

Also, you detailed out how to install Apache, but left out the part on the VM installation.

Better luck next time!

virtualization rocks (/content/consolate-put-your-servers-virtualbox-vm#comment-356526)


Submitted by Daniel Molina (http://coder.cl/) (not verified) on Sun, 10/03/2010 - 15:46.

Virtualization rocks, VMs are easy to install and backup, so you can prepare an image for
certain server and then just copy that image with VBoxManage clonehd. This is a very good
solution.

vbox - love it (/content/consolate-put-your-servers-virtualbox-vm#comment-356465)


Submitted by Anonymous (not verified) on Fri, 10/01/2010 - 05:53.

I have run Winxp and win7 vboxes on my Ubuntu laptop and they have been amazingly solid.
I also have three vbox servers running on a Win 2003 standard edit server and they have run
without failure for over a year - day in day out. Vbox is excellent but I wonder how long it will
be available.

Bridged vs NAT + Port Forwarding? (/content/consolate-put-your-servers-virtualbox-vm#comment-356463)


Submitted by mm (not verified) on Fri, 10/01/2010 - 04:19.

A question: instead of setting networking to "bridged" and forward the router's requests on
port 80 to the guest's port 80, couldn't it be set to "NAT" forwarding the router requests to the
host's port 80 and using the VBox port forwarding to redirected it again to guest's port 8080?
Especially concerning security, which is the better practice?

Personally I use VirtualBox (/content/consolate-put-your-servers-virtualbox-vm#comment-356459)


Submitted by bennyboy (/users/bennyboy) on Fri, 10/01/2010 - 02:48.

Personally I use VirtualBox for different purposes such as testing new


distributions, new softwares... the only problem I see with VirtualBox is that it
was Sun ... and now Oracle. What's the future of this product then!?
(/users/bennyboy)

Headless VBox Web UI (/content/consolate-put-your-servers-virtualbox-vm#comment-356432)


Submitted by Eric Birgersson (not verified) on Thu, 09/30/2010 - 16:28.

I just want to add some information about running headless VirtualBox. There is a web
interface in beta phase. I've used it for a few days now and I find it very useful.

Here it is: http://code.google.com/p/phpvirtualbox/ (http://code.google.com/p/phpvirtualbox/)

VirtualboxHeadless server (/content/consolate-put-your-servers-virtualbox-vm#comment-356428)


Submitted by Anonymous (not verified) on Thu, 09/30/2010 - 11:53.

I use virtualbox for personal server. If you have installed a server distro without GUI you can
run it as a headless server, it's easy to make a virtual machine this way, just read the
virtualbox manual. I use one server for my personal web page with few users. One server for
long boring jobs such as encoding terabyte of movies to highest quality, you can also put one
for a virtual desktop, the possibilities are endless, well... not endless, it depends how much RAM you have.:)

Nice! (/content/consolate-put-your-servers-virtualbox-vm#comment-356411)
Submitted by Doug.Roberts (/users/dougroberts) on Thu, 09/30/2010 - 08:38.

Good article, Michael. We continue to follow similar paths -- I've got a VirtualBox
article coming up soon too. I've been using VB here for several years now, it's a
good product. I hope Oracle doesn't kill it or otherwise put it at risk. I don't trust
Oracle. (/users/dougroberts)

I agree (/content/consolate-put-your-servers-virtualbox-vm#comment-356430)
Submitted by Tachyon_1 (not verified) on Thu, 09/30/2010 - 14:18.

VBox is a great product and it would be a shame if Oracle were to crap that up
with their new "I wanna be like SCO" mantra.
I can just see them turning VBox into a paid product with a crippled free version
remaining.
That or suing everyone who ever touched it.

So far the only coding effort I've seen Oracle put into anything is writing scripts to strip out Sun's
name and logo from everything and slap theirs in it's place. Even the new OpenOffice icons are
ugly.

Here's to hoping a great product stays great and free with it's new overlords.

VirtualBox (/content/consolate-put-your-servers-virtualbox-vm#comment-356412)
Submitted by Michael Reed (/users/michael-reed) on Thu,
09/30/2010 - 08:51.

Thanks Doug. I'm a fan of VirtualBox, and I seem to spend a lot


of time working with it. It's one of about half a dozen tools that I
can't manage without. (/users/michael-reed)

http://www.linuxjournal.com/content/consolate-put-your-servers-virtualbox-vm 3/5
10/13/2014 Consolidate: Put Your Servers into a VirtualBox VM | Linux Journal
UK based freelance writer Michael Reed (http://www.unmusic.co.uk/) writes about technology, retro
computing, geek culture and gender politics.

Eh... (/content/consolate-put-your-servers-virtualbox-vm#comment-356410)
Submitted by David Lane (/users/david-lane) on Thu, 09/30/2010 - 08:36.

I have found VB to be...testy. Sometimes it works and sometimes it doesn't.


Some guests spin up without problems and other die horrible deaths without any
reason behind the guest going away.
(/users/david-lane)
If you just want a server, doing simple things, in a development environment, it
might work for you. If you want to use it for more sophisticated, long term production operations, I wouldn't
bet the farm on it.

David Lane, KG4GIY is a member of Linux Journal's Editorial Advisory Panel


(http://www.linuxjournal.com/node/1000303) and the Control Op for Linux Journal's Virtual Ham Shack
(http://www.linuxjournal.com/ham)

What is your configuration? (/content/consolate-put-your-servers-virtualbox-vm#comment-356425)


Submitted by Doug.Roberts (/users/dougroberts) on Thu, 09/30/2010 -
11:22.

David,

What OS are the host and guests running? I've been running the (/users/dougroberts)
latest VB, 3.2.8 currently, on a Linux Mint (Ubuntu derivative) host
here at the home office. The main guest that I use is a Windows XP image that has been rock
steady under VB for 3 years, but I've also run other guests like various Ubuntus, and ChromeOS
never have had a problem. Well, except for this one bug that sometimes caused local file access
to be slow from within the XP image to the host filesystem. But that bug has been fixed for nearly
a year now.

At work -- my company offices are on the east coast, 2,000 miles away from my Santa Fe home
office -- I have several VB hosts running guests in production which have also been rock solid for
several years. I maintain them via VNC, but about the only maintenance they need is to have
updates installed as they are released.

--Doug

Please share more about that XP-host bug (/content/consolate-put-your-servers-virtualbox-


vm#comment-356499)
Submitted by Lee (not verified) on Sat, 10/02/2010 - 01:09.

Doug, Can you please explain more about how to fix that XP-host bug
or give a KB-article reference? Lee

Bug info (/content/consolate-put-your-servers-virtualbox-vm#comment-356508)


Submitted by Doug.Roberts (/users/dougroberts)
on Sat, 10/02/2010 - 09:07.

Lee,

Here's the bug report: (/users/dougroberts)


http://www.virtualbox.org/ticket/1728
(http://www.virtualbox.org/ticket/1728)

However, this bug has been fixed since about 4 releases ago, it does not
exist in the current VB release (3.2.8).

--Doug

Haven't had a problem (/content/consolate-put-your-servers-virtualbox-vm#comment-356424)


Submitted by chrisj (not verified) on Thu, 09/30/2010 - 11:00.

I'm currently using VB (ose) for external facing DNS servers and a FTP server.

I haven't had any problems with them, and they get hit pretty hard.

http://www.linuxjournal.com/content/consolate-put-your-servers-virtualbox-vm 4/5
10/13/2014 Consolidate: Put Your Servers into a VirtualBox VM | Linux Journal

AROUND THE WEB ALSO ON LINUX JOURNAL WHAT'S THIS?

Mobile Threat Monday: A Look Back Learn GNU/Linux the Fun Way 2 comments
World News
Monitoring Android Traffic with
How to Attract Advertising Revenue Wireshark 4 comments
Without Banner Ads Disqus Cluetrain at Fifteen 4 comments

0 Comments Linux Journal Login

Sort by Best Share Favorite

Start the discussion

Be the first to comment.

Subscribe d Add Disqus to your site Privacy

Webinar More Resources (/whitepapers) Webinar More Resources (/whitepapers)

One Click, Universal Protection: Linux Backup and Recovery Webinar


Implementing Centralized Security (http://www.linuxjournal.com/content/register-linux-
backup-and-recovery-webinar)
Policies on Linux Systems
(http://www.linuxjournal.com/content/watch-one-click-
universal-protection-implementing-centralized- Most companies incorporate backup procedures
security-policies-linux-system) for critical data, which can be restored quickly if a
loss occurs. However, fewer companies are
prepared for catastrophic system failures, in which
As Linux continues to play an ever increasing role they lose all data, the entire operating system,
in corporate data centers and institutions, applications, settings, patches and more, reducing
ensuring the integrity and protection of these their system(s) to bare metal. After all, before
systems must be a priority. With 60% of the data can be restored to a system, there must be a
world's websites and an increasing share of system to restore it to.
organization's mission-critical workloads running
on Linux, failing to stop malware and other In this one hour webinar, learn how to enhance
advanced threats on Linux can increasingly your existing backup strategies for better disaster
impact an organization's reputation and bottom recovery preparedness using Storix System
line. Backup Administrator (SBAdmin), a highly flexible
bare-metal recovery solution for UNIX and Linux
Learn More (http://www.linuxjournal.com/content/watch- systems.
one-click-universal-protection-implementing-centralized-
security-policies-linux-system)
Learn More (http://www.linuxjournal.com/content/register-
linux-backup-and-recovery-webinar)
Sponsored by Bit9
Sponsored by Storix

http://www.linuxjournal.com/content/consolate-put-your-servers-virtualbox-vm 5/5

Vous aimerez peut-être aussi