Compiling YAWS on Ubuntu

Part 4 of the series, documenting the setup of an Erlang test platform. In this episode, it’s YAWS (discussed previously here) that we’re adding.

Another dependency first:

sudo apt-get install libpam0g-dev

Now we can get, build and install YAWS from SVN. Note that as before I’m grabbing a specific revision so I have a stable and repeatable setup:

svn -r 1129 co https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws
cd yaws
./configure
make
sudo make install

To use YAWS in embedded mode, you need to start up Erlang with something like the following:

erl -pa /usr/local/lib/yaws/ebin -yaws embedded true

Finally, here’s a very small test program that just serves static files from the ‘wwwtest’ subdirectory of the directory you run from. Before running this, you need an empty directory .yaws/yaws/yawstest off your home directory. To be honest I don’t know why yet as the parameter is newly added and (surprise surprise) undocumented, but the final part corresponds to the second parameter to make_default_gconf.

-module(yawstest).
-export([main/0]).
 
-include("/usr/local/lib/yaws/include/yaws.hrl").
 
main() ->
    application:start(yaws),
    GC = yaws_config:make_default_gconf(false,"yawstest"),
    SC = #sconf{port = 8001,
		servername = "ubuntu01",
		listen = {0,0,0,0},
		docroot = "wwwtest"},
    yaws_api:setconf(GC, [[SC]]).

Stick some documents in wwwroot, run the above and test away.

  1. Hao’s avatar

    Thanks for the guide. I forgot to run “sudo apt-get install libpam0g-dev” before installing YAWS. Now it works well.

    Reply

  2. asantiago’s avatar

    Sorry, i’m trying embed yaws in an application and i’m confused. Do you have to execute yaws first to be able to run it in a program?. I cant understand whats the difference between embed mode and normal mode if i have to do this. Should I include yaws in a folder lib of my app and make a bash script to run it?

    Thank you for your post and sorry for my english.

    Reply