Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
237 lines (150 sloc) 6.9 KB

Building the W3C Markup Validation Service from source


This guide provides a step-by-step walk-through to build and install the W3C Markup Validation Service (herein referred to as Validator) from its source files. It assumes minimal prior system administration experience, uses the latest versions and includes all functionality of the validator. The target Linux distribution is Ubuntu Precise, though each step will be similar for any distribution.

Installing Ubuntu

Note: this section can be skipped if you're already familiar with installing Ubuntu and/or have a Linux system running.

We will be using a Vagrant managed VirtualBox install as a base system.

  1. Download and install Vagrant from a pre-built package

  2. From the command line, download an Ubuntu Precise box with:

     vagrant box add precise32
  3. Create an instance of Ubuntu Precise with:

     mkdir validator
     cd validator
     vagrant init
  4. Edit the generated Vagrantfile and tell Vagrant to use the precise32 box: = "precise32"
  5. Launch the virtual machine:

     vagrant up

Your Ubuntu virtual machine should now be up and running. Confirm by running:

vagrant ssh

Optional: if running Validator through a web server (see Optional section below), uncomment the following line in the generated Vagrantfile to enable port forwarding: "forwarded_port", guest: 80, host: 8080

... then reload the virtual machine with:

vagrant reload

Installing Validator

1. Installing Validator dependencies

  1. Install build packages:

     sudo apt-get update
     sudo apt-get install build-essential libtool automake
  2. Install tidyp:

     cd ~
     mkdir build
     cd build
     tar -xzf tidyp-1.04.tar.gz
     cd tidyp-1.04
     sudo make install
     sudo ldconfig
  3. Install validator dependencies:

     sudo apt-get install libosp-dev libxml2-dev zlib1g-dev libwww-perl
  4. Install required Perl Modules:

     perl -MCPAN -e "install Bundle::W3C::Validator"

When prompted, type:

  • yes to pre-configure as much as possible
  • sudo to make modules available system-wide
  • yes to choose a local CPAN mirror
  • y to install JSON::XS

2. Install Validator

Note: optionally on this step you can choose to download a more up-to-date DTD library from the development repository at

  1. Download the Validator and the sgml-lib DTD library:

     cd ~/build
     tar -xzf validator-1_3-release.tar.gz
  2. Install the Validator:

     sudo mkdir -p /usr/local/validator
     sudo mv markup-validator-validator-1_3-release/httpd/cgi-bin /usr/local/validator
     sudo mv markup-validator-validator-1_3-release/{htdocs,share,httpd} /usr/local/validator

3. Configure and test Validator

  1. Copy the default configuration:

     sudo mkdir -p /etc/w3c
     sudo cp /usr/local/validator/htdocs/config/* /etc/w3c/
  2. Edit /etc/w3c/validator.conf as necessary.

    Note, if you plan to validate documents on a private network, enable the following option in the validator.conf file:

     Allow Private IPs = yes
  3. Test the Validator's command line tool:

     /usr/local/validator/cgi-bin/check uri=

If some HTML output is printed to screen, Validator is installed and ready to go.


The following sections provide guides to optional but common usages of Validator. HTML5 validation

  1. Install's build dependencies:

     sudo apt-get install git default-jdk
  2. Build

     cd ~/build
     git clone validator-nu
     cd validator-nu
     export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
     python build/ all

    Note, if you encounter a Java exception, run the build script again:

     python build/ all
 should now be running on port 8888:

     INFO::Started SocketConnector@

    Confirm by killing the server (CTRL+C) and re-starting it with:

     python build/ run
  3. Configure Validator to use the engine by adding the following line in /etc/w3c/validator.conf:

     HTML5 = http://localhost:8888/

Running at system start up

  1. Create an unprivileged user account:

     sudo groupadd validator-nu
     sudo useradd -r -c " daemon" -g validator-nu \
       -d /usr/local/validator-nu -s /bin/false validator-nu
  2. Install system-wide:

     sudo mv ~/build/validator-nu /usr/local/
     sudo chown -R validator-nu:validator-nu /usr/local/validator-nu
  3. Create a launch script:

     cat << EOF | sudo tee /usr/local/bin/validator-nu
     cd /usr/local/validator-nu
     su -s '/bin/sh' -c 'python build/ run >logs/validator-nu.log 2>&1' validator-nu
     sudo chmod +x /usr/local/bin/validator-nu
  4. Edit /etc/rc.local and add the following line before exit 0:


After rebooting, should be running. Confirm by running:

sudo ps aux | grep validator-nu

Set up a web server

Here, we'll be using Apache but the same principles apply to any web server.

  1. Install Apache and its Perl bindings:

     sudo apt-get install apache2 libapache2-mod-perl2
  2. Copy Validator's HTTP server configuration:

     sudo cp /usr/local/validator/httpd/conf/httpd.conf /etc/w3c/
     sudo ln -s /etc/w3c/httpd.conf /etc/apache2/conf.d/w3c-validator.conf
     sudo ln -s /usr/local/validator/htdocs/ /var/www/w3c-validator
  3. Restart Apache:

     sudo apachectl graceful

Validator should now be set up and ready to go. Browse to http://localhost/w3c-validator (or http://localhost:8080/w3c-validator if running in Vagrant) to see it running.


The author would like to thank the Validator Team's official install guide, which forms the basis of much of this document.


Copyright 2012 Tom Vincent, licensed under the Creative Commons Attribution 3.0 Unported License.