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!