How to install and use w3c markup validator on Ubuntu 13.10 locally? I know I can install it by installing following packages:

sudo apt-get install libapache2-mod-perl2   
sudo apt-get install w3c-markup-validator

but how do I configure it to use it same way as on-line version (that is by web browser), but locally?

  • Its uses CGI to work, and is probably designed for a webserver - the script on ubuntu seems to be located at /usr/lib/cgi-bin/w3c-markup-validator/check. Also: stackoverflow.com/a/16673201/2943276
    – Wilf
    May 24, 2014 at 14:42
  • @Rafal : if you find a way to use the validator offline, can you reply with detailed steps please, I was also looking for that :)
    – MrVaykadji
    May 24, 2014 at 14:59

2 Answers 2


Good news! So if you have apache2 already installed, you install W3C Validator and Perl:

sudo apt-get install w3c-markup-validator libapache2-mod-perl2

The issue is that the w3c-markup-validator package hasn't been updated to install properly on 13.10+ (I'm on 14.04). To fix it manually:

sudo ln -s /etc/w3c/httpd.conf /etc/apache2/conf-enabled/w3c-markup-validator.conf

I then had an issue where /usr/lib/cgi-bin didn't have the correct permissions. This is due to a problem in /etc/apache2/conf-available/serve-cgi-bin.conf where it will only give the correct permission if the module is being loaded. It appears this version of perl isn't listed in the IfModule statement. To fix this:

sudo gedit /etc/apache2/conf-available/serve-cgi-bin.conf

You want it to look like this:

<IfModule mod_alias.c>
    <IfModule mod_cgi.c>

    <IfModule mod_cgid.c>

    <IfModule mod_perl.c>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Require all granted

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Once you're done with these steps you have to symlink validator's html directory to /var/www/html:

sudo ln -s /usr/share/w3c-markup-validator/html /var/www/html/w3c-validator 

Once the file is linked and the changes are in place, all you have to do is restart the Apache server:

sudo service apache2 restart

Check that it's all working


CSS might be missing from validator page in the browser, but validation should work well.

  • try sudo xdg-open http://localhost/w3c-validator or to change httpd.conf's permission with sudo chown $USER:$USER /etc/w3c/httpd.conf and sudo chmod 777 /etc/w3c/httpd.conf.
    – MrVaykadji
    May 25, 2014 at 19:52
  • I gave that a try and it didn't work. I'm pretty sure the problem is in /etc/w3c/httpd.conf and how it uses mod_rewrite to link to /usr/lib/cgi-bin/w3c-markup-validator/check. Possibly an Apache rule about running code perl that's not in the docroot...
    – Skarard
    May 25, 2014 at 20:15
  • 1
    /etc/w3c/validator.conf might also need checking. E.g. there might be a validator.conf.dpkg-dist that is different. Apr 13, 2016 at 5:29

After applying @Skarard's answer the W3CValidator showed up but the check didn't work. There were errors in /var/log/apache2/error.log

  AH01337: Could not parse expr "$QUERY_STRING = /(^|[;&])debug(=[^0]?)?(\\b|$)/" in /usr/share/w3c-markup-validator/html/header.html: Parse error near '$'
  AH01337: Could not parse expr "$includeJS = 1" in /usr/share/w3c-markup-validator/html/header.html: Parse error near '$'
  AH01337: Could not parse expr "$debug = 1" in /usr/share/w3c-markup-validator/html/header.html: Parse error near '$'
  AH01337: Could not parse expr "$feeds = 1" in /usr/share/w3c-markup-validator/html/header.html: Parse error near '$'

So I found out that the validator.conf file was pointing to a wrong schema location. There was a left over validator.conf.dpkg-dist

/etc/w3c# diff validator.conf validator.conf.dpkg-dist 
<     Library = /usr/share/xml/xhtml/schema/dtd
>     Library = /usr/share/xml/w3c-sgml-lib/schema/dtd
< Allow Private IPs = yes
> Allow Private IPs = no
<   Allow = http
>   Allow = data,ftp,http,https
< #
< # Source for the "Tip of The Day" blurbs.
< <Tips>
<   Include tips.cfg
< </Tips>

I moved the validator.conf.dkpk-dist to validator.conf and restarted apache. The error messages in /var/log/apache2/error.log were still there.

Apache 2.4 being in use seemed to be the reason as outlined in https://stackoverflow.com/questions/14878076/how-does-expression-work-in-apache-2-4) so i had to add

SSILegacyExprParser On

to the w3c-markup-validator.conf file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.