Pages

Showing posts with label virtualbox. Show all posts
Showing posts with label virtualbox. Show all posts

May 1, 2014

Vagrant: "Development environments made easy."

I've been using VirtualBox as my go-to hypervisor provider. It's usually how I test out Linux ISOs I've downloaded to see if they run before I load said ISO into a USB device. Another thing I've recently used virtual machines for is to create a development server to, for example, host a LAMP stack, which I prefer not to install into my main OS. I do like to use the same tools when developing stuff across the board. This is where Vagrant shines! You basically create a Vagrant VM to get a LAMP server running but use the tools on your host OS (e.g. text editor, IDE, etc.) to edit the web pages that are served by the VM.

Vagrant is a great tool for spinning up VirtualBox VMs as fast as possible. You create a Vagrantfile, a file which holds the settings on how to setup a VM; things like which base box to base your VM off of, to the networking setup or to the shared folders the VM will have with the host machine. The Vagrantfile is written in Ruby code but it is very easy to grok and you don't need to learn the language to create one.

In this post, I gloss over my usage of Vagrant.

February 23, 2014

A Basic CentOS LAMP Server Build in VirtualBox

I've been using Fedora for more than a month now and I wanted to create a virtual machine (VM) in VirtualBox which I can use for learning web development. I usually go for a Debian based VM but this time, since I'm on Fedora, then I decided to go with CentOS.

I have used CentOS before so I knew that it took a bit of effort to get it up and running. In this post, I put down my notes into how I built a CentOS VM for a basic LAMP server.

Creating the CentOS guest

The CentOS OS is easy enough to install. Just download the ISO image from their site; I chose to use the CentOS-6.5-x86_64-minimal.iso image. It's just a matter of using the downloaded image as the DVD media for the VM. Installation is straightforward and fast and finishes in under 30 minutes.

NOTE: In my setup, I have set 2 network interfaces -- one for Host-only adapter and another for NAT adapter. At this time of posting, I suggest to set Host-only as adapter 1 and NAT as adapter 2 because I've run into some issues with the network interfaces. Host-only interface is for accessing the VM from the host machine while the NAT interface takes care of the connection to the Internets.

Enable networking in the CentOS guest

Network interfaces are down by default in CentOS [1]. So there is a need to do some manual configuration. To show the interfaces, use command ip addr show. Since my setup has 2 network adapters set in VirtualBox, the result of that command shows eth0 and eth2, for the Host-only adapter and the NAT adapter, respectively. The configuration files for these are located in /etc/sysconfig/network-scripts/ifcfg-ethX where X is the interface number.

February 5, 2014

A note on VirtualBox installation in Fedora

I use VirtualBox [1] a lot. It's actually one of the first few applications I install after doing a fresh install of a Linux distribution. As I am currently using Fedora, I noted that it's best to do it like so:

    $ sudo yum install VirtualBox kmod-VirtualBox

kmod-VirtualBox is the kernel module for VirtualBox. If for instance, when logged in using, say, for example kernel 3.12.8-300.fc20.x86_64 and doing sudo yum install VirtualBox, then the kmod-VirtualBox-3.12.8-300.fc20.x86_64... will be installed along as a dependency. Now this is fine, as long as you are using the 3.12.8-300.fc20.x86_64 kernel, the kernel module for VirtualBox is useable. But then a new kernel update comes along, say kernel 3.12.9-301.fc20.x86_64 and you log out, reboot the computer and choose this shiny new kernel. Then once logged in, you run (assuming you do things from a terminal emulator, like I do) VBoxManage startvm 'my-virtual-machine' --type headless and the STDOUT spews forth an error telling you that kernel modules haven't been installed for the current kernel (or something like that).

That's where the meta-package kmod-VirtualBox comes in. So when there's a kernel update in Fedora, the specific VirtualBox kernel module will automatically be installed for that kernel. Then you can happily continue using VirtualBox in Fedora.

---

[1] VirtualBox package I used are in the RPMFusion third-party repository which needs to be activated before it can be used.