Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tlvince/w3c-validator-guide

Build guide for W3C HTML validator
https://github.com/tlvince/w3c-validator-guide

Last synced: 11 days ago
JSON representation

Build guide for W3C HTML validator

Awesome Lists containing this project

README

        

# Building the W3C Markup Validation Service from source

## Preamble

This guide provides a step-by-step walk-through to build and install the [W3C
Markup Validation Service][home] (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][vagrantdl]
2. From the command line, download an Ubuntu Precise box with:

vagrant box add precise32 http://files.vagrantup.com/precise32.box

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:

config.vm.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:

config.vm.network "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
wget https://github.com/petdance/tidyp/archive/1.04.tar.gz
tar -xzf tidyp-1.04.tar.gz
cd tidyp-1.04
./acgo
./configure
make
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 http://dvcs.w3.org/hg/markup-validator/file/tip/htdocs/sgml-lib

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

cd ~/build
wget https://github.com/w3c/markup-validator/archive/validator-1_3-release.tar.gz
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=http://www.w3.org

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

## Optional

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

### Validator.nu HTML5 validation

1. Install Validator.nu's build dependencies:

sudo apt-get install git default-jdk

2. Build Validator.nu:

cd ~/build
git clone https://github.com/validator/validator.git validator-nu
cd validator-nu
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
python build/build.py all

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

python build/build.py all

Validator.nu should now be running on port 8888:

INFO::Started [email protected]:8888

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

python build/build.py run

4. Configure Validator to use the Validator.nu engine by adding the following
line in `/etc/w3c/validator.conf`:


HTML5 = http://localhost:8888/

#### Running Validator.nu at system start up

1. Create an unprivileged user account:

sudo groupadd validator-nu
sudo useradd -r -c "Validator.nu daemon" -g validator-nu \
-d /usr/local/validator-nu -s /bin/false validator-nu

2. Install Validator.nu 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
#!/bin/sh
cd /usr/local/validator-nu
su -s '/bin/sh' -c 'python build/build.py run >logs/validator-nu.log 2>&1' validator-nu
EOF
sudo chmod +x /usr/local/bin/validator-nu

4. Edit `/etc/rc.local` and add the following line before `exit 0`:

/usr/local/bin/validator-nu

After rebooting, Validator.nu 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][localhost] (or
[http://localhost:8080/w3c-validator][localhost8080] if running in Vagrant) to
see it running.

## References

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

## License

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

[cc]: http://creativecommons.org/licenses/by/3.0/
[home]: http://validator.w3.org/
[OpenSP]: http://sourceforge.net/projects/openjade/
[vagrant]: http://vagrantup.com/
[vagrantdl]: https://www.vagrantup.com/downloads.html
[validator.nu]: http://about.validator.nu/
[localhost]: http://localhost/w3c-validator/
[localhost8080]: http://localhost:8080/w3c-validator/
[official]: http://validator.w3.org/docs/install.html