Every repository with this icon (
Every repository with this icon (
Install Nitrogen on Mochiweb
DEPRECATED
Now you create a new application using the `nitrogen` command and change ‘inets’ to ‘mochiweb’ in the ebin/myweb.app file.
For more follow the Installing Nitrogen instructions
Nitrogen hooks into Mochiweb through your application’s loop(Req, DocRoot) function.
1. Download and build Mochiweb.
- Download Mochiweb to a directory called MOCHIWEB_ROOT.
- Under MOCHIWEB_ROOT run ‘make’.
2. Download Nitrogen and build Nitrogen
- Download Nitrogen to a directory called NITROGEN_ROOT
- Under NITROGEN_ROOT run ‘make’.
3. Make a new Mochiweb Application.
- Under MOCHIWEB_ROOT, run:
chmod +x scripts/new_mochiweb.erl; ./scripts/new_mochiweb.erl nitrogen_demo ..
4. Copy the Nitrogen Web Files
Nitrogen needs the files under NITROGEN_ROOT/www to run. Copy these files to a nitrogen directory under …/nitrogen_demo/priv/www
mkdir ../nitrogen_demo/priv/www/nitrogen; cp NITROGEN_ROOT/www/* ../nitrogen_demo/priv/www/nitrogen
- or -
ln -s NITROGEN_ROOT/www ../nitrogen_demo/priv/www/nitrogen
- or on windows -
download and install the junction.exe command into your windows/system32 directory from http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
junction ../nitrogen_demo/priv/www/nitrogen NITROGEN_ROOT/www
The goal is to have these files served under http://localhost:8000/nitrogen
5. Set up wf_global
- Copy NITROGEN_ROOT/Quickstart/src/wf_global.erl to the nitrogen_demo/src directory.
- Edit wf_global.erl, replace the signkey with a unique signkey that only you know. Nitrogen uses this value to uniquely sign data that it sends to the browser.
- Compile wf_global.erl
6. Add nitrogen to the deps folder
ln -s NITROGEN_ROOT ../nitrogen_demo/deps/nitrogen
- or on windows -
junction ../nitrogen_demo/deps/nitrogen NITROGEN_ROOT
7. Update your main Mochiweb loop.
- Edit ../nitrogen_demo/src/nitrogen_demo_web.erl, and in loop/2:
- Add a call to
wf:init()as the first line in the function. - Look for the two
case Path ofstatements. - Add a clause to each one saying:
"web/" ++ _ -> wf_mochiweb:loop(Req);
8. Make nitrogen_demo
cd nitrogen_demo; make
9. Start your Application
Run start-dev.sh, and navigate to http://localhost:8000/web/test
Congratulations, you have now successfully run your first Nitrogen application.







