Deploying clckwrks In a Shared Hosting Environment: Preparation (Tested on Bluehost)

This post is the first in a series that will chronicle my efforts to get involved in the development of the clckwrks Haskell web development framework. It will describe how to get the development environment set up on a Bluehost shared hosting server. After doing this, the getting started guide on clckwrks.com can be followed to get clckwrks going.

The software to be installed in this guide are the Glasgow Haskell Compiler, Cabal, Darcs and the Crypto++ Library. To follow this guide, it is necessary to have shell access to the hosting account. Let's begin!

Installing the Glasgow Haskell Compiler

The Glasgow Haskell Compiler (GHC) is "An optimizing compiler for Haskell, written in Haskell".

Download, extract and install GHC 7.4.2 in the home directory:

:~$ mkdir ghc
:~$ wget http://www.haskell.org/ghc/dist/7.4.2/ghc-7.4.2-x86_64-unknown-linux.tar.bz2
:~$ tar -xvjf ghc-7.4.2-x86_64-unknown-linux.tar.bz2
:~$ cd ghc-7.4.2/
:~$ ./configure -prefix=/homeX/your_bluehost_username/ghc
:~$ make install
:~$ cd ..

Add the new GHC directory with binaries to the PATH environment variable. To do this, edit the .bashrc file in the HOME directory. For example with nano:

:~$ nano .bashrc

and add the following line at the end of the .bashrc file:

export PATH=/homeX/your_bluehost_username/ghc/bin:$PATH

Save the file (ctrl-o in nano) and load the new settings:

:~$ source .bashrc

and then test it:

:~$ ghci

You should see something similar to:

GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.a free and open source, cross-platform version control system, like git, mercurial or subversion but with a very different approach.
Loading package base ... linking ... done.
Prelude>

Now GHC is installed and ready to go!

Installing Cabal, Darcs and the Crypto++ Library

Cabal is "a system for building and packaging Haskell libraries and programs". The cabal command line utility will be used to install packages necessary to run clckwrks.

Darcs is "a free and open source, cross-platform version control system, like git, mercurial or subversion but with a very different approach". Darcs will be used to fork the clckwrks.com source to create new projects.

Crypto++ is "a free C++ class library of cryptographic schemes". Crypto++ is required to build some of the packages that clckwrks depends on.

Download, extract and install the cabal-install package. The package has a bootstrapping setup process that will download and install all of its dependencies (including Cabal).

:~$ wget http://hackage.haskell.org/packages/archive/cabal-install/1.16.0.2/cabal-install-1.16.0.2.tar.gz
:~$ tar -xvzf cabal-install-1.16.0.2.tar.gz
:~$ cd cabal-install-1.16.0.2
:~$ chmod +x bootstrap.sh
:~$ ./bootstrap.sh

Upon completion, the bootstrapping script will advise that cabal is now installed in "~/.cabal". Now add the cabal binaries to the PATH environment variable. Since TMPDIR (os specific temporary directory) is mounted as noexec in the server environment it also has to be changed to a directory under the home directory. This will allow packages that have to execute scripts during installation to install without errors.

:~$ nano .bashrc

and add the following lines:

export PATH=/homeX/your_bluehost_username/.cabal/bin:$PATH
alias cabal="TMPDIR=/homeX/your_bluehost_username/tmp cabal"

Save the file and load the new settings:

:~$ source .bashrc

and then test it:

:~$ cabal

You should see something similar to:

cabal: no command given (try --help)

To install Darcs, update the cabal package list and issue the cabal install command:

:~$ cabal update
:~$ cabal install darcs

Darcs should install without errors and it is now time to install the Crypto++ library. Use the following commands:

:~$ mkdir .cryptopp cryptopptmp
:~$ cd cryptopptmp
:~$ wget http://prdownloads.sourceforge.net/cryptopp/cryptopp562.zip
:~$ unzip -a cryptopp562.zip

Open "GNUmakefile" with nano, uncomment the following line and save the file.

# CXXFLAGS += -fPIC

Issue the make command to build the static library. Then install the library to ~/.cryptopp.

:~$ make static dynamic test
:~$ gmake install PREFIX=/homeX/your_bluehost_username/.cryptopp/

To ensure the shared library can be found when installing packages that depend on it, add the following line to the .bashrc file and load the new settings.

export LD_LIBRARY_PATH=/homeX/your_bluehost_username/.cryptopp/lib:$LD_LIBRARY_PATH

That's it! The the sever is now prepped for the getting started guide on clckwrks.com to be followed. Have fun!

__________________

Sando George Sando George is a web development freelancer and a budding Computer Science researcher. He also serves as the CTO of Social Capital Holdings, a startup company dedicated to raising funds for charitable and socially responsible organizations.