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.
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.
-
Download and install Vagrant from a pre-built package
-
From the command line, download an Ubuntu Precise box with:
vagrant box add precise32 http://files.vagrantup.com/precise32.box
-
Create an instance of Ubuntu Precise with:
mkdir validator cd validator vagrant init
-
Edit the generated
Vagrantfile
and tell Vagrant to use theprecise32
box:config.vm.box = "precise32"
-
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
-
Install build packages:
sudo apt-get update sudo apt-get install build-essential libtool automake
-
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
-
Install validator dependencies:
sudo apt-get install libosp-dev libxml2-dev zlib1g-dev libwww-perl
-
Install required Perl Modules:
perl -MCPAN -e "install Bundle::W3C::Validator"
When prompted, type:
yes
to pre-configure as much as possiblesudo
to make modules available system-wideyes
to choose a local CPAN mirrory
to install JSON::XS
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
-
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
-
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
-
Copy the default configuration:
sudo mkdir -p /etc/w3c sudo cp /usr/local/validator/htdocs/config/* /etc/w3c/
-
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
-
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.
The following sections provide guides to optional but common usages of Validator.
-
Install Validator.nu's build dependencies:
sudo apt-get install git default-jdk
-
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 SocketConnector@0.0.0.0:8888
Confirm by killing the server (CTRL+C) and re-starting it with:
python build/build.py run
-
Configure Validator to use the Validator.nu engine by adding the following line in
/etc/w3c/validator.conf
:<External> HTML5 = http://localhost:8888/ </External>
-
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
-
Install Validator.nu system-wide:
sudo mv ~/build/validator-nu /usr/local/ sudo chown -R validator-nu:validator-nu /usr/local/validator-nu
-
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
-
Edit
/etc/rc.local
and add the following line beforeexit 0
:/usr/local/bin/validator-nu
After rebooting, Validator.nu should be running. Confirm by running:
sudo ps aux | grep validator-nu
Here, we'll be using Apache but the same principles apply to any web server.
-
Install Apache and its Perl bindings:
sudo apt-get install apache2 libapache2-mod-perl2
-
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
-
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 http://tlvince.com/contact/, licensed under the Creative Commons Attribution 3.0 Unported License.