I've been working lately on a multi-player web game, to actually get to know HTML Canvas (on the client) and Yesod (on the server) properly. I have a first fully functional version of the game, so now is the time to think about hosting. Michael initiated a discussion about it, and in the meantime I decided to investigate Amazon since they offer free instances now on EC2.
The free AMIs (images) come with a version of Linux specific to Amazon, but apparently binary compatible with CentOS, on which GHC and the Haskell Platform have been reported to successfully build.
These are the steps I followed to get everything working, hopefully they can be useful to somebody else. So as per the Amazon Getting Started guide, you connect to your instance with the ec2-user.
First we install through the package manager some useful packages:
sudo yum install make
sudo yum install gcc
sudo yum install zlib-devel
sudo yum install glut
sudo yum install glut-devel
I didn't find gmp, so I downloaded and installed in the default location:
curl -O ftp://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.bz2
tar -xjvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure
make
sudo make install
But afterwards I had issues building some Haskell packages because it didn't like the default install folder of /usr/local/lib, it preferred /usr/lib, so I did:
sudo cp /usr/local/lib/libgmp.* /usr/lib/
But I suppose ./configure --prefix=/usr/lib/ would be the preferred way to do that.
Libbsd is also required otherwise unix-compat fails:
curl -O http://libbsd.freedesktop.org/releases/libbsd-0.2.0.tar.gz
tar -xzvf libbsd-0.2.0.tar.gz
cd libbsd-0.2.0
sudo make install
Then for GHC, I just downloaded the generic binary and installed that. I decided to install Haskell under my home folder.
curl -O http://haskell.org/ghc/dist/7.0.2/ghc-7.0.2-i386-unknown-linux.tar.bz2
tar -xjvf ghc-7.0.2-i386-unknown-linux.tar.bz2
cd ghc-7.0.2
./configure --prefix=/home/ec2-user/haskell
make install
Make sure we know how to find it:
export PATH=$PATH:/home/ec2-user/haskell/bin
Then get the Haskell Platform source and build that, since there is no binary (yet) for our platform:
curl -O http://lambda.galois.com/hp-tmp/2011.2.0.0/haskell-platform-2011.2.0.0.tar.gz
tar -xzvf haskell-platform-2011.2.0.0.tar.gz
cd haskell-platform-2011.2.0.0
./configure --prefix=/home/ec2-user/haskell
make
make install
Once you're there, it's back to familiar ground:
cabal update
cabal install yesod
And there we are!! My deployment platform is ready!
6 comments:
Hi. Thanks for the nice guide, worked like a charm for me.
I was able to skip the gmp build from source (gmp and gmp-devel were installable from yum). I also had to install make using yum.
Sadly I ran out of memory while trying to compile (well... link) Haskell Platform (on a 64 bit instance). Setting LDFLAGS to "-no-keep-memory" and it seems to be working. Albeit very very very slowly.
I'll get back to you in a year or two if it fails.
Thomas, thanks, I've added make to the list of yum, must have done it and forgot about it. I didn't manage to get gmp from yum, though. Funny.
Zoe, I used a 32 bit instance I think, and while it was slow, I didn't run into memory issues.
Great post - have you had any developments in this? I.e. any easier way of doing it...
Er, no, Andriy. I haven't pursued that web project so I'm not using my instance any more. So no better advice, sorry!
The ghc distribution has moved to http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-x86_64-unknown-linux.tar.bz2
Post a Comment