10 Feb 2012

Erlang, Nitrogen and Mochiweb installation

I absolutely love Erlang and Nitrogen, and I decided to build my next project with.
Both do have quite a steep learning curve, and Nitrogen isn't that well documented yet. But the productivity increase for developing webapplications (compared to for instance php and smarty) is really amazing. I can get so much more done in the same time.

Although nitrogen runs out of the box on my macBook, it does not install smoothly on Linux.
Here's how I got the server for www.akulahjodohmu.com running:

1.
Install the dependencies. I'm running Debian and Erlang is in the repository. But it's an older version so I'll get a more recent one from the Erlang site in step 2. First:
apt-get install libncurses5-dev git openssl libssl-dev

2.
Get the release R14B04 from Erlang.org. Although R15 is available it's still very new and I'm not keen on running a fresh major release on a production system.  R14B03 is been used a lot with Nitrogen, but unfortunately has a ssl Cache bug in it, which will leak memory if you use ssl. This project uses the  Erlang inets and ssl modules to connect to Facebook.

3.
Now tar -zxvf the download and cd into its main directory
run make and after it make install

4.
Next, get the latest Nitrogen source from the website and run tar -zxvf nitrogen.tar.gz
cd into the main directory and run ./apps/get_mochiweb.sh

5.
If you run make now, it will probably complain about this:

{"init terminating in do_boot","Module mochiglobal potentially included by two different applications: mochiweb and nitrogen."}

The solution is to replace the line in ./rel/reltool.config that says:

{app, nitrogen, [{incl_cond, include}]},

with:

{app, nitrogen, [{incl_cond, include},
         {mod, mochiglobal, [{incl_cond, exclude}]},
     {mod, mochijson2, [{incl_cond, exclude}]}]},

This is a small adaption for the newer sources, for older versions look here.

6. now run make rel_mochiweb and you're good to go. Your complete Nitrogen server is in the ./rel/nitrogen directory and can be started from with ./nitrogen start  from the ./rel/nitrogen/bin/ directory. The default site runs on http://[yourhost]:8000/







No comments:

Post a Comment