Pages

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 12, 2014

Virtual Environments for Python

I dabble with Python programming every now and then. Nothing serious, just casual n00bz stuff. Along the way, I stumbled across virtualenv. In a nutshell, it's a tool to create isolated Python environments. Python, like most programming languages, have 3rd-party modules (or libraries) that can be installed and used within your very own projects. Using pip makes it easy to do (granting pip is installed on your system).

Installing 3rd-party modules directly onto your bare-metal system may be fine for most cases, so you might be thinking why isolated Python environments? Well, if you're like me, I prefer to alter my base system as less as possible in terms of installed software. But from the top of my head, here are some reasons to consider using virtualenv.

  1. You don't have root privileges in your current system to issue a sudo pip install module command
  2. You work with a lot of Python projects that use different combinations of 3rd-party modules
  3. You are concerned that installing all 3rd-party modules may cause conflicts with each other
  4. You are OCD, like I am
  5. You like anything "virtual"...

The first 3 reasons could be valid...the last 2 can be ignored. Anyway, here's a use-case to illustrate my workflow.

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.