W3C Unicorn - Tutorial

Tags : unicorn
Maxime THOMAS on 17 of Aug 2010 - 05pm

For some time, I was searching a cool and efficient web to check websites against a reference tool, like W3C validators.

The launch of W3C Unicorn was a windfall : packing all validators and giving us the opportunity to install and enhance such validators.

In this tutorial, you will learn how to set up an Unicorn instance by your self.

W3C Unicorn

Requirements

  • OS : Debian Lenny
  • Packages installed : make gcc bz2 zlib gzip
  • Other software : Python, Mercurial

Part 1 - Check out

  • Type the following commands :
cd
mkdir unicorn
cd unicorn
hg --debug clone https://dvcs.w3.org/hg/unicorn
  • At the end you should have a new unicorn directory

Part 2 - Compilation of Unicorn

Installation of Java

  • The Java package supported by Debian is java 1.5.0 and Unicorn need 1.6.0. To fix that, we must install the official non free package form Sun Micro Systems / Oracle.
  • Type the following commands :
vi /etc/apt-sources.list
  • Add the following lines at the end :
deb http://ftp2.fr.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.fr.debian.org/debian/ lenny main contrib non-free
  • Type the following commands :
apt-get update
apt-get upgrade
apt-get install sun-java6-jre sun-java6-plugin sun-java6-jdk sun-java6-fonts
  • It will take a while but it will install all Sun java stuff.
  • To check eversything is ok :
java -version
  • You should have something like :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

Installation of Apache Ant

  • Get on the Apache Ant webiste : http://ant.apache.org/srcdownload.cgi
  • Copy the url of the latest version (At this time 1.8.1) : http://mirror.ibcp.fr/pub/apache/ant/source/apache-ant-1.8.1-src.zip
  • Type :
cd
mkdir ant
cd ant
wget http://mirror.ibcp.fr/pub/apache/ant/source/apache-ant-1.8.1-src.zip
gunzip apache-ant-1.8.1-src.zip
cd apache-ant-1.8.1-src
export ANT_HOME="<your directory>/ant/apache-ant-1.8.1-src"
export PATH="$PATH:{$ANT_HOME}/bin"
  • Check the values :
echo $ANT_HOME
echo $PATH

Installation of Apache Ivy

  • Get on the website : http://ant.apache.org/ivy/download.cgi
  • Copy the link of the latest version (2.2.0 at this time) : http://apache.multidist.com/ant/ivy/2.2.0-rc1/apache-ivy-2.2.0-rc1-bin.zip
  • Type :
cd
mkdir ivy
cd ivy
wget http://apache.multidist.com/ant/ivy/2.2.0-rc1/apache-ivy-2.2.0-rc1-bin.zip
gunzip apache-ivy-2.2.0-rc1-bin.zip
cd apache-ivy-2.2.0-rc1-bin
cp ivy-2.2.0-rc1.jar ../../ant/apache-ant-1.8.1-src/lib/.

Compilation of Unicorn

  • Type :
cd
cd unicorn/unicorn
ant retrieve generate_observer generate_tasklist default_conf war
  • A war file will be produced in unicorn/unicorn/dist

Part 3 : Installation in Tomcat

Installation of Tomcat

  • Get Tomcat on the website :
  • Unzip
  • If you work in a company that use a proxy, you can specify the proxy settings at the Java Command Line :
export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=proxy.xxx.xx -Dhttp.proxyPort=xxx" 

Installation of Unicorn

  • Put the war in the TOMCAT_HOME/webapps
  • Change to TOMCAT_HOME/bin
  • Launch ./startup.sh
  • To check, go to url http://domain:8080/unicorn

Part 4 : Update

  • To update the project, you just have to do :
hg pull
hg update
ant clean generate_observer generate_tasklist compress-css compress-js default_conf war
  • Re deploy the war file