Haskell Blog Rewrite - Session 7

I am really stubborn, so I never completely gave up on my little pet project of
re-writing my blog as a Haskell CGI app. I also
didn't give up on using my budget host. (Partly because I have even less money
than before). So, the saga continues.

Due to the following facts:

GHC compiles to native code

My dev box is quite different from my web site host box

I have no shell account on my host

...the binaries I produce on my dev box won't run on my host(
/lib/tls/libc.so.6: version 'GLIBC_2.4' not found etc, and worse if I try to
compile static binaries).

So I had to set up a VM for creating binaries. This took quite some doing,
and below are the gory details. (In fact I have spared you quite a lot, this
took days, but would take much less now. It's easy when you know how...).
Conclusions at the bottom.

Installed CentOS 4.5, the OS used on my host, as a VirtualBox VM

I did this ages ago, so I can't remember how long this took, or
how I did it, should be fairly straightforward.

Got host networking working - this took hours of messing around,
but eventually these got me there:

Later, I decided that rsync was better, since it didn't require
checking really experimental stuff into the repos. It does mean I have to
remember not to edit on the build box, since it is no longer a branch.:

Then followed the build instructions in README, with
'./configure --prefix=/home/build/local' so I wouldn't mess up my VM.
Time to go off and do a work out...45 minutes later, it's still
building...another hour...right, I'll be leaving my machine on
tonight then...

In the morning...bummer, out of disk space! The GHC build directories are
using over 1 Gb of space, I didn't anticipate that, my 4 Gb VM disk wasn't
large enough.

So, time to resize the VirtualBox disks. Except that gets a bit
complicated, since CentOS uses LVM, and I have no idea what I'm doing. But,
hang on, LVM should make life much easier actually, and remove the need to
actually resize the hard disk -- I can just add another. Once I figure out
how to use it (took a while). So I:

Created a new 20 GB (dynamic) hard disk with the
VirtualBox GUI

Created a single 'Linux LVM' partition in it using cfdisk
(by booting from a Damn Small Linux CD ISO file, CentOS doesn't have
cfdisk for some reason, I probably could have used sfdisk or
something, but I'm familiar with cfdisk)

(Except I didn't do just that, and in my
experimentation I managed to make my VM unbootable by
deleting a hard disk that I had added in the manner above.
Cue another hour working out what to do, ending (happily)
with booting the CentOS install DVD in 'rescue' mode, running
lvm and vgreduce --removemissing VolGroup00, hooray, my
VM boots again!)

Then, having extended the logical volume that holds the root filesystem,
you've got to resize the filesystem, too. But you can't, since it's
mounted. (I thought LVM was supposed to make this stuff easier? This
sucks...) So, back to the CentOS rescue CD. It finds the installed system,
and mounts it all, so you then have to do:

19GB free - woot! That ended up being much harder than anticipated, but
at least I know about LVM now. Well, I know that it works, but it's not that
much fun, and when I get a new machine and make my current one into a backup
server, it will be an OpenSolaris box with all the ZFS goodness, and not a
Linux box.

Soooo...try again to build GHC, hopefully I can just do 'make && make
install' again and it will carry on and work...takes another hour...

Finally, everything is setup, I run my build script for my web
app, generate the binaries, upload them to my host. The moment of truth:
can I create and access and SQLite database with my binaries? I go to:
http://lukeplant.me.uk/cgi-bin/installdb.cgi

Conclusions

Set up for developing a Haskell CGI web app is hard. (Do I get a
prize for understatement of the year? Do I? Oh, thank you!)

In general, you will need a VM for building binaries.

Even if you are developing on a Linux box, web hosts tend to use
pretty old and stable software, so you might have binary
incompatibilities. This is only going to get worse with 64bit etc.

Even if your web site host gives you shell access, they probably
won't have a recent enough GHC installed, and building it takes 1.5 GB of
disk space, (and lots of CPU and memory for quite a few hours), which you
probably don't want to do on your hosting box. (NB: actually building GHC
is usually not required, installing the binary should work, but it might
not, as in my case.)

Make sure your VM has more than enough space.

VirtualBox sucks for setting up host networking, VMPlayer is much
easier.

You have to be really stubborn. Hopefully, some idea of just how
much effort it might take, and some of the pitfalls to avoid, will help
you.

Make sure you factor in the time to do all this if you have any kind
of deadline!