Yaws

From GeilThings

Jump to: navigation, search
Yaws
General
Version 1.96
Stable 1.96
Function Web Server
Files
Config File /etc/yaws/yaws.conf
Log File /var/log/yaws/*
Scripts
Version Script yaws -v
Start /etc/init.d/yaws start
Stop /etc/init.d/yaws stop

Contents

General

  • Written in Erlang.
  • Version: yaws -v
  • yaws 1.91 does not run under Erlang R15B. Rebuilding it did not help.
    • The 1.91 version from GitHub (Decmeber 23, 2011) works.

Installation

See http://yaws.hyber.org/yman.yaws?page=yaws.conf

NEWVERSION=1.92
cd /opt
wget http://yaws.hyber.org/download/yaws-${NEWVERSION}.tar.gz
tar -xvzf yaws-${NEWVERSION}.tar.gz
# The tar command above will create a soft link yaws -> ${NEWVERSION} under /opt
 
# CentOS 6.2: For compiling with latex, dvips, pdflatex, epstopdf
yum install texlive-latex
# make may fail with error message: pam_appl.h: No such file or directory; solution
yum install pam-devel
 
cd yaws
# Read about options.
./configure --help
./configure --localstatedir=/var --sysconfdir=/etc
make
make install
 
# Final message lines:
## etc files went into        /etc
## executables went into      /usr/local/bin
## library files went into    /usr/local/lib/yaws
## var files went into        /var
## default docroot went into  /var/yaws/www
## (and conf file seems to be in /etc/yaws/yaws.conf)

Errors while installing Yaws

  • Error 1: After running make, ... epam.c:2:22: error: pam_appl.h: No such file or directory.
Solution: See http://marc-abramowitz.com/archives/2007/04/18/building-yaws-erlang-web-server-for-ubuntu/.
yum search libpam0g-dev or libpam: NADA, yum search pam-devel found it.
From http://www.rpmseek.com/rpm/pam-devel-0.99.6.2-4.el5.i386.html?hl=de&cx=0:-:0:7290008:0:0:0::
PAM (Pluggable Authentication Modules) is a system security tool that allows system administrators to set authentication policy without having to recompile programs that handle authentication. This package contains header files and static libraries used for building both PAM-aware applications and modules for use with PAM.
yum install pam-devel
  • Error 2: After running yaws (yaws -i), error message: Bad conf: "Expect directory at line 8 (logdir /usr/local/var/log/yaws)"
Solution: Kein Wunder: Directory does not exist. Anyway the log files should go somewhere else.
Edit /etc/yaws/yaws.conf, change logdir = /var/log/yaws
mkdir /var/log/yaws

Configuration

http://yaws.hyber.org/configuration.yaws

  • port changed to 82 in one virtual server, the other two default servers were deleted.
  • listen 127.0.0.1 in the same virtual server, since apache httpd is going to be the only web server facing outside requests; apache will act as a proxy server and redirect calls to yaws.

Running

# Interactive mode
yaws -i
 
# Daemon mode: 
# Start the daemon (called id)
yaws --daemon [--id id]
# Stop it
yaws --daemon --stop [--id id]
# e.g.
yaws --daemon --id 1
 
# Best way for me (stop / restart also work):
/etc/init.d/yaws start
 
# An erlang process can be found using ps aux:
ps aux | grep yaws
## /usr/local/lib/erlang/erts-5.8.4/bin/beam.smp -K true -- -root /usr/local/lib/erlang -progname erl -- -home /root -- -noshell 
##                                               -noinput -heart -pa /usr/local/lib/yaws/ebin -run yaws -conf /etc/yaws/yaws.conf

Backup

# Variables
 
# Application name.
APP=yaws
 
# Actual Date.
DATE=`date +%Y-%m-%d`
 
# Version. As of yaws 1.91, output will be in the format:
# Yaws 1.91
RAWVERSION=`yaws -v`
 
# Get Version as Substring.
OLDVERSION=${RAWVERSION:5}
 
# The script breaks if variable names are not enclosed with {}
BACKUPDIR=/home/backup/$APP/${APP}_${OLDVERSION}_${DATE}
 
# Create backup directory if it does not exist.
if [ ! -d "${BACKUPDIR}" ]
then
    mkdir -m 755 -p ${BACKUPDIR}
fi
 
# Backup configuration file.
cp /etc/yaws/yaws.conf ${BACKUPDIR}/yaws.conf

Upgrade Yaws

######### START OF EDIT #########
 
APPNAME=yaws
# If I want to backup, set it to TRUE.
ISBACKUP=TRUE
# BACKUPROOTDIR is only relevant if ISBACKUP=TRUE
BACKUPROOTDIR=/home/backup
# The directory where I want to download the files to be installed.
DOWNLOADDIRECTORY=/opt
DATE=`date +%Y-%m-%d`
 
######### END OF EDIT #########
 
# Backup first (I only want to copy the configuration file).
 
# Version. As of yaws 1.9x, output will be in the format: Yaws 1.9x
# yaws does not be to be running for this.
RAWVERSION=`yaws -v`
OLDVERSION=${RAWVERSION:5}
echo ${OLDVERSION}
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[Yaws]]|%3FStable&format=json" http://www.geilthings.com/api.php` 
# Get Version as Substring.  
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2:  
# http://stackoverflow.com/questions/4392106/sed-extract-string-between-first-occurrence-of-match1-and-next-occurrence-of-m  
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`  
echo $NEWVERSION
 
if [[ ${ISBACKUP} == "TRUE" ]]; then
  # The script breaks if variable names are not enclosed with {}
  BACKUPDIR=${BACKUPROOTDIR}/${APPNAME}/${APPNAME}_${OLDVERSION}_${DATE}
  echo "Backup directory: " ${BACKUPDIR}
 
  # Create backup directory if it does not exist.
  if [ ! -d "${BACKUPDIR}" ]; then
    mkdir -m 755 -p ${BACKUPDIR}
  fi
  /bin/cp -fr /etc/yaws/yaws.conf /home/backup/yaws/${APPNAME}_${OLDVERSION}_${DATE}/yaws.conf
fi
 
# Stop yaws.
/etc/init.d/yaws stop
 
cd ${DOWNLOADDIRECTORY}
wget http://yaws.hyber.org/download/yaws-${NEWVERSION}.tar.gz
 
tar -zxvf yaws-${NEWVERSION}.tar.gz
cd yaws-${NEWVERSION}
 
./configure --localstatedir=/var --sysconfdir=/etc
make
 
# Rename /etc/yaws/yaws.conf, otherwise it will not be replaced with a new one.
# (One of the final messages after "make install" would report "Keeping old config file /etc/yaws/yaws.conf").
# I want to get the "new" yaws.conf file, which I will edit later.
mv /etc/yaws/yaws.conf /etc/yaws/yaws.conf.${DATE}
 
make install
 
# Make a backup of the new yaws.conf file before editing it.
cp /etc/yaws/yaws.conf /etc/yaws/yaws.conf.${NEWVERSION}.original
 
# Edit /etc/yaws/yaws.conf
### logdir = /var/log/yaws
# Remove all servers
# Add my server:
###<server localhost>
###        port = 82
###        listen = 127.0.0.1
###        docroot = /var/www/html/myerlangsite
###        dir_listings = false
###        auth_log = true
###        statistics = true
###</server>
 
# Start yaws.
/etc/init.d/yaws start
 
# Chack that service is running.
ps aux | grep yaws
# Something like this should appear:
# root     32116  0.2  0.4 115864 14164 ?        Sl   17:52   0:00 /usr/local/lib/erlang/erts-5.9/bin/beam.smp -K true -- -root /usr/local/lib/erlang -progname erl -- -home /root -- -noshell -noinput -heart -pa /usr/local/lib/yaws/ebin -run yaws -conf /etc/yaws/yaws.conf
 
# Test a yaws application.

Yaws 1.91 and Erlang R15B

  • Yaws 1.91 does not work with Erlang R15B (should be R15B00; it does work with R15B01).
  • The yaws 1.91 git version (23.Dec.2011) works with Erlang R15B, however "configure" has to be created by autoconf.
  • Downloading the yaws 1.91 git version and running autoconf in this yaws directory throws an error. Solution: Upgrade autoconf.
  • CentOS 5.7 brings autoconf 2.59. Dependencies: automake, libtool, php-pear, and php53-devel. So a better solution is not upgrading but making a current autoconf version available.
cd /opt
wget https://github.com/klacke/yaws/zipball/master --no-check-certificate
mv master master.zip
mkdir yaws-new
unzip master.zip -d yaws-new
cd yaws-new/
mv /opt/yaws-new/klacke-yaws-c3d6b7c/* /opt/yaws-new/
mv /opt/yaws-new/klacke-yaws-c3d6b7c/.gitignore /opt/yaws-new/
 
# Using CentOS 5.7 autoconf, version 2.59.
autoconf
# Error:
# configure.in:219: error: AC_LANG: unknown language: Erlang
# autoconf/lang.m4:123: _AC_LANG_SET is expanded from...
# autoconf/lang.m4:132: AC_LANG is expanded from...
# configure.in:219: the top level
# autom4te: /usr/bin/m4 failed with exit status: 1
 
# Solution: Use a different autoconf version.
# https://github.com/klacke/yaws/issues/74
 
cd /opt
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar xvfz autoconf-latest.tar.gz
cd autoconf-2.68/
# Install autoconf under a different directory from the already installed autoconf 2.59.
./configure --prefix=/opt/autoconf
make
make install
# autoconf -V
# 2.59
# /opt/autoconf/bin/autoconf -V
# 2.68
 
# Re-try Yaws Installation.
 
cd /opt/yaws-new
export PATH=/opt/autoconf/bin:$PATH
/opt/autoconf/bin/autoconf
# The file "configure" is created now.
 
./configure --localstatedir=/var --sysconfdir=/etc
make
 
# Rename /etc/yaws/yaws.conf, otherwise it will not be replaced with a new one.
# (One of the final messages after "make install" would report "Keeping old config file /etc/yaws/yaws.conf").
# I want to get the "new" yaws.conf file, which I will edit later.
mv /etc/yaws/yaws.conf /etc/yaws/yaws.conf.old
 
make install
 
# Make a backup of the new yaws.conf file before editing it.
cp /etc/yaws/yaws.conf /etc/yaws/yaws.conf.1.91.original
 
# Edit /etc/yaws/yaws.conf
### logdir = /var/log/yaws
# Remove all servers
# Add my server:
###<server localhost>
###        port = 82
###        listen = 127.0.0.1
###        docroot = /var/www/html/myerlangsite
###        dir_listings = false
###        auth_log = true
###        statistics = true
###</server>
 
# Start yaws.
/etc/init.d/yaws start
 
# Check that service is running.
ps aux | grep yaws
# Something like this should appear:
# root     32116  0.2  0.4 115864 14164 ?        Sl   17:52   0:00 /usr/local/lib/erlang/erts-5.9/bin/beam.smp -K true -- -root /usr/local/lib/erlang -progname erl -- -home /root -- -noshell -noinput -heart -pa /usr/local/lib/yaws/ebin -run yaws -conf /etc/yaws/yaws.conf
 
# Test a yaws application.

Versions

Software name Version number Version date
Yaws 1.96
1.92
1.91
1.90
19 March 2013
23 December 2011
15 December 2011
20 July 2011

Comments

blog comments powered by Disqus