This is a text-only version of the following page on https://raymii.org: --- Title : Local W3C HTML5 Validator Server Author : Remy van Elst Date : 27-12-2013 URL : https://raymii.org/s/tutorials/Local_W3C_HTML5_Validator_Server.html Format : Markdown/HTML --- ![w3 validator][1] This tutorial shows you how to set up a local instance of the w3c html validator, including HTML5 validation support via a local instance of the Validator.nu HTML5 validator. The online w3 validator has strict limits and will ban you for some time if you validate to often. So if you for example have a local unit test to check a website you will get banned a lot. Which is understandable of course, it is a free service. They provide all source code plus it is in the debian repositories, it is dead simple to set up one yourself.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:

I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!

I've used Ubuntu 13.10 because that has the latest w3 test (1.3). If you use Ubuntu 12.04 LTS and you want the latest version you can install the two packages (`w3c-markup-validator` and `w3c-sgml-lib`) from the raring repositories (13.04), that works just fine. ### Contents * Installing required packages * Compiling / Installing HTML5 Validator.nu * Configuring the w3c-validator * Upstart script for the HTML5 validator ### Installing required packages Install all required packages: apt-get install w3c-markup-validator mercurial subversion python default-jdk This will install everything required for the w3 validator and for the HTML 5 one (that is Java). It will also pull down Apache. After the install finished you can reach your validator already at `http://server.ext/w3c-validator`. However, it is not yet configured for HTML5 validation, which is kinda required for todays web. ### Compiling / Installing the HTML5 Validator.nu The W3 validator itself does not do HTML5 validation. It does support using external services to do it, and we are going to do it with the HTML5 validator from . Create a folder: mkdir /usr/share/html5-validator cd /usr/share/html5-validator Set the `JAVA_HOME` path. export JAVA_HOME=/usr/lib/jvm/java-6-openjdk Clone the latest validator source: hg clone https://bitbucket.org/validator/build build Start the build: python build/build.py all If you encounter a Java exception, run the build script again. I had to do it three times: python build/build.py all If it all works after a few tries, the validator runs at `localhost:8888`: INFO::Started SocketConnector@0.0.0.0:8888 Kill it with CTRL+C and continue reading. We first configure the W3 validator and then create an upstart script for the Validator.nu one. ### Configuring the w3c-validator I need to validate hosts in private networks, so I changed the below option in `/etc/w3c/validator.conf`: Allow Private IPs = yes Enable the HTML5 validator by uncommenting the following: ## Enable checking documents via external services. ## The example config below assumes that you have installed the validator.nu ## engine on the same machine as the markup validator. ## See http://about.validator.nu/ for installation instructions. HTML5 = http://localhost:8888/html5/ #CompoundXML = http://localhost:8888/ ### Upstart script for HTML5 validator Create the upstart script to start the HTML5 validator at boot: vim /etc/init/html5-validator.conf Contents: description "Validator.nu HTML5 Validator" start on (local-filesystems and net-device-up) stop on runlevel [016] chdir /usr/share/html5-validator exec python build/build.py --control-port=8889 run respawn Save and start it: start html5-validator Afterwards you can access your validator via `http://server/w3c-validator`. It supports the HTML5 validator from there, but you can also access it directly at `http://server:8888`. ### Security note The validator.nu service is running as root and there are no limits on both validators. Make sure you only run it on a trusted network, or properly secure it. [1]: http://i.imgur.com/jqyin7n.png [2]: https://www.digitalocean.com/?refcode=7435ae6b8212 --- License: All the text on this website is free as in freedom unless stated otherwise. This means you can use it in any way you want, you can copy it, change it the way you like and republish it, as long as you release the (modified) content under the same license to give others the same freedoms you've got and place my name and a link to this site with the article as source. This site uses Google Analytics for statistics and Google Adwords for advertisements. You are tracked and Google knows everything about you. Use an adblocker like ublock-origin if you don't want it. All the code on this website is licensed under the GNU GPL v3 license unless already licensed under a license which does not allows this form of licensing or if another license is stated on that page / in that software: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Just to be clear, the information on this website is for meant for educational purposes and you use it at your own risk. I do not take responsibility if you screw something up. Use common sense, do not 'rm -rf /' as root for example. If you have any questions then do not hesitate to contact me. See https://raymii.org/s/static/About.html for details.