Installing and configuring Bitnami Liferay 6.1 Appliance in VirtualBox 4.0

This is a quick overview of the steps that I have used to configure the Bitnami 6.1 Liferay Appliance to work with VirtualBox on my Mac running Lion (10.7). This is moderately advanced and I’ve left some steps out in the interest of brevity. Please let me know if you need more detail.

Prerequisites

media_1343833746507.png

You need VirtualBox 4.x. At the time of writing, this is VirtualBox 4.1.18. This needs to be installed and working for you already before you undertake any of the other steps in this guide. Next, you’ll need to download the Bitnami “appliance” for Liferay 6.1. Visit http://bitnami.org/stack/liferay . Do not click on the “Download virtual machine” tab, but navigate down the page and locate the 32 bit virtual machine download. This is built on top of Ubuntu 10.10. Once you’ve located the file, download and unzip it.

Copying the disk images that you will use to create the virtual machine

media_1343834293933.png

The virtual machine image is in a format that is most easily imported by VMWare’s tools. Given that we are using Virtualbox, that won’t work for us. Create a new folder outside of your downloads directory to hold the disk images. I created “Library/VirtualBox/HardDisks/Bitnami” and moved the decompressed folder into that location, but this choice is really up to you. I routinely clear out my Downloads folder, so it didn’t make sense for me to leave the disk images in the Downloads folder.

The screenshot above shows the contents of “Library:VirtualBox:HardDisks:Bitnami” The red arrow points to the name of the “master” disk image record for the Bitnami virtual machine. We’ll use that in a minute.

Create the virtual machine and connect it to the Bitnami disk

media_1343835050419.png

Start up VirtualBox and create a new virtual Linux machine. If you have the RAM (I have 8GB in this MacBook), assign 2GB to the virtual machine. It will make it much more responsive once you are running Liferay. By default, VirtualBox will want to create a SATA adapter, rather than an IDE adapter for the disk drive. Delete the SATA adapter from the VM and add an IDE adapter. Then choose the existing Bitnami disk by navigating to the file indicated in the screen shot for the previous step and attach the disk to the IDE adapter.

The settings for the machine should look now look something like the above screenshot.

Boot the virtual machine to test it out

media_1343836047216.png

Go ahead and start up the virtual machine. You still have a few steps left.
As indicated in the boot screens, you will need to change the bitnami user’s password.
Go ahead and do that. At this point the machine should be up and running, but you will still have no way to access the machine from outside. This is because, by default, VirtualBox configures networking to be NATted. The Bitnami vm probably has the address 10.0.2.15 and can reach the internet. However, you cannot reach Liferay on the guest machine just yet. Also, by default, SSH is not started on the local machine. Because I prefer to use SSH to access the machine rather than the VirtualBox console tool, I always enable SSH. Do this to enable SSH: “sudo update-rc.d ssh defaults”. This will ensure that ssh always starts when you boot the bitnami vm. Second, do “sudo service ssh start” to actually start the ssh daemon.

Now we need to configure port forwarding to make sure that we can access the Tomcat server and SSH server from the host machine.

Configure port forwarding to create access to services on the guest machine

media_1343837060357.png

We’re almost there. Now you need to turn on port forwarding from the guest to the host in order to access the services on the guest. Most likely, the address of the guest is 10.0.2.15. However, you can confirm that by typing “sudo ifconfig eth0” in the guest machine’s console window. In VirtualBox, click on Devices -> Network Adapters… In the screen that appears, click on “Port Forwarding“.

Now, fill in the blanks as shown in the above screen shot.

We have configured it so that the guest machines Tomcat instance is now accessible at 127.0.0.1:8080. SSH is likewise accessible at 127.0.0.1:8022 and I’ve also made MySQL accessible at 127.0.0.1:8306. The choice of local ports is up to you. If you have questions about port forwarding, there is more information available in the VirtualBox manual.

Success!

media_1343837209659.png

At this point, you should be able to visit the Liferay virtual instance by pointing your web browser at http://localhost:8080. If everything works as intended, you should see a screen similar to the above. At this point, you are ready to explore Liferay within your virtual machine.

One of the reasons that I like this set up is that it allows me to take snapshots using VirtualBox’s snapshot feature. I can then easily roll back to that snapshot should there be an issue or if we are testing the impact of various changes. Also this is relatively secure. The virtual machine is able to access the web (so that you can test Liferay portlets that consume global resources such as RSS feeds and the like); howewer, it should not be accessible beyond the local host machine.

Let me know in the comments if this is helpful, not helpful, etc. Thanks!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s