W3C Validator in Ubuntu 14.04.1
Since Ubuntu 14.04.1 has just been released recently, I want to see if there’s anything improved in installing the w3c markup validator with it. The basic information is covered by Simply Testable here.
But there’s some extra steps you need for the latest changes. So I’m just putting the extra steps along with the original steps to get it going.
To start, fire up the Terminal app.
Most nuts and bolts are installed by default so you only need to take care a few things.
First, you’ll need to manually create the directory
sudo mkdir /etc/apache2/conf.d
because this is where the w3c-markup-validator package wants to install. Otherwise you’ll end up with a bunch of error messages to trace.
You would want to install these 7 extra packages proceeding further.
sudo apt-get install apache2 mercurial subversion python openjdk-6-jdk git libapache2-mod-perl2
Then install the w3c validator package should run smoothly:
sudo apt-get install w3c-markup-validator
git wasn’t mentioned elsewhere because this is a recent change in the HTML5 validator. Thus you will need git to get the latest source.
The perl module is required for the w3c validator actually, and there’s some changes you need to make to the conf file.
You will need to do these before w3c validator works
sudo ln -s /etc/w3c/httpd.conf /etc/apache2/conf-enabled/w3c-markup-validator.conf
Added the mod_perl module part to the cgi-bin conf:
sudo gedit /etc/apache2/conf-available/serve-cgi-bin.conf
It will look like the following:
<IfModule mod_alias.c> <IfModule mod_cgi.c> Define ENABLE_USR_LIB_CGI_BIN </IfModule> <IfModule mod_cgid.c> Define ENABLE_USR_LIB_CGI_BIN </IfModule> <IfModule mod_perl.c> Define ENABLE_USR_LIB_CGI_BIN </IfModule> <IfDefine ENABLE_USR_LIB_CGI_BIN> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Require all granted </Directory> </IfDefine> </IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Low and behold, you will need to actually enable CGI-BIN for Apache first. Otherwise you will end up with error when you try to check any url.
sudo a2enmod cgi
Now restart apache with:
sudo service apache2 restart
You should now be able to reach http://localhost/w3c-validator/ and do a basic validation.
To install the HTML5 validator at /usr/share/html5-validator, do the following:
sudo ln -s /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-openjdk sudo gedit /etc/enviroment
Append the following lines:
JAVA_HOME=/usr/lib/jvm/java-6-openjdk PATH=$PATH:$JAVA_HOME/bin
and then save the file. For more details, please read setting JAVA_HOME for all users.
To make the JAVA_HOME available to sudo commands, type at command line:
sudo visudo
Then add at the bottom of the file and save.
Defaults env_keep += "JAVA_HOME PATH"
Back to Terminal, do the followings:
sudo mkdir /usr/share/html5-validator && cd /usr/share/html5-validator sudo hg clone https://bitbucket.org/validator/build build sudo python build/build.py --legacy all sudo python build/build.py --legacy all
The HTML5 validator is running now and you can verify by going to http://localhost:8888/
But there’s not good enough for our daily use, right? We want it to start upon startup. Let’s just Ctrl-C to break the HTML5 validator for now. Then we’ll create the startup script at
sudo gedit /etc/init/html5-validator.conf
Put the following into it.
description "Validator.nu HTML5 Validator"
start on runlevel [234] stop on runlevel [0156]
chdir /usr/share/html5-validator exec python build/build.py --legacy --control-port=8889 run respawn
With this, the HTML5 validator will start upon reboot, and you can start and stop it with:
sudo service html5-validator start/stop
The last item here is to enable w3c validator to work with private IP and HTML5 validation.
sudo gedit /etc/w3c/validator.conf
Change
Allow Private IPs = no
to
Allow Private IPs = yes
Uncomment the following line. (Do NOT put the extra HTML at the end of the URL)
HTML5 = http://localhost:8888/html5/
Restart Apache
sudo service apache2 restart
Now we got a fully working w3c validator!

