Install wc3 markup validator locally

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>
        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

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

http://localhost/w3c-validator

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


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 
42c42
<     Library = /usr/share/xml/xhtml/schema/dtd
---
>     Library = /usr/share/xml/w3c-sgml-lib/schema/dtd
57c57
< Allow Private IPs = yes
---
> Allow Private IPs = no
75c75
<   Allow = http
---
>   Allow = data,ftp,http,https
118,123d117
< 
< #
< # 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.