Build and install Yaws

Yaws is hosted at http://github.com/klacke/yaws. (Prior to release 1.81 Yaws was hosted at Sourceforge.)

Tested releases are downloadable from the Yaws download directory at http://yaws.hyber.org/download

To check out the latest release and build a number of prerequisites are required. (All code example below on Ubuntu)

To check out the sources do

# git clone git://github.com/klacke/yaws.git
    

To build and to what is knows as a local install, e.g. a developer install do:

# cd yaws
# autoconf; ./configure --prefix=/path/to/yaws; make; make install
    

Alternatively, to make a standard install

# cd yaws
# ./configure --help
# ./configure --localstatedir=/var --sysconfdir=/etc
# make
# make install
    

The above commands will checkout the HEAD source, build it and install it at 127.0.0.1:80 with the docroot set to the local documentation.

A local install does install yaws at http://127.0.0.1:8000

This is the typical mode of operation while either just trying out yaws, or hacking yaws. This will install a template configuration file yaws.conf in ${prefix}/etc/yaws (${prefix} is the value of the --prefix option passed during the execution of the configure script). If this file exists, the old file will not be overwritten.

To run a locally installed system, we run the installed yaws script ${prefix}/bin/yaws.

A standard install will install yaws in /usr/local. A configuration file /etc/yaws/yaws.conf will also be installed unless the file already exists. The default config file will set up the system to listen on http://127.0.0.1:80

Building with Rebar

Yaws can alternatively be built using rebar. Assuming you already have rebar installed, simply type

$ rebar get-deps compile
    

This fetches all dependencies and builds Yaws.

The rebar_release page explains how to use rebar to create an Erlang release for an application that depends on Yaws.

Running yaws

The yaws executable is a shell script which invokes the erlang system and instructs it to start yaws. The command line flags for yaws are documented in man page for yaws(1)

When developing yaws code, the interactive mode is ideal. Typically, yaws is then started as:

# yaws -i
       

Run yaws as a daemon as

# yaws --daemon
       

All command line flags to yaws are described in the man page for yaws.

Configuring Yaws

Web server configuration can be supplied to yaws in either of two ways depending on whether we run yaws as a standalone daemon or if we run yaws as an embedded application inside another Erlang program.

The yaws configuration is described in man page for yaws.conf (5)

Embedded mode

It is possible to run yaws in embedded mode where yaws is part of a larger application. When running yaws in embedded mode, it is often not possible to let yaws read its configuration data from /etc/yaws/yaws.conf.

The function yaws_api:setconf(Gconf, Groups) can be used by an other erlang process to explicitly set a yaws configuration at runtime. To execute Yaws in embedded mode, it must be started with the environment {embedded, true}

The embedded mode is fully described at embed.yaws

Valid XHTML 1.0!