April 21, 2007
How to install the W3C Markup Validator on LAMP
Table Of Contents
About this Howto
This howto will list my installation steps to the W3C Markup Validator on linux running LAMP.
Prerequisites
Install OpenSP SGML parser
Download the OpenSP source tar ball from http://openjade.sourceforge.net.
For more details see:The general Installation guide.
./configure make make install
Install Perl modules
The list of Perl modules can be found in the "check" script.
- CGI
- Config-General
- File-Spec
- HTML-Parser
- HTML-Template
- HTTP-Request
- LWP
- Net-IP
- Set-IntSpan
- Text-Iconv
- Text-Wrap
- IO-File
- URI.
perl -MCPAN -e shell
install [Module::Name]
It is recommended to install Bundle::W3C:Validator to take care of all these Perl module dependencies.
install Bundle::W3C::Validator
Installation
- Obtain The W3C Validator source tar ball and the DTD library from the W3C Validator site.
- Unpack the Validator tarball to a temporary directory.
- mkdir /usr/local/validator.
- mkdir /srv/www/validator . This is the vhost directory.
- mkdir /etc/w3c.
- Move all the files and subdirectories from temp/validator/htdocs to /srv/www/validator.
- Move all the files from temp/validator/httpd/cgi-bin to /srv/www/validator.
- chmod 755 /srv/www/validator/check.
- Copy all the files from temp/validator/htdocs/config to /etc/w3c .
- Copy header.html and footer.html from /srv/www/validator to a new subdirectory of /usr/local/validator called htdocs.
- Copy sgml-lib subdirectory from /srv/www/validator to /usr/local/validator/htdocs.
- Copy share subdirectory from /srv/www/validator to /usr/local/validator.
For more details see Linux (Slackware) by Nick Talbott.
Files Configuration
Virtual Host Configuration
Open Apache httpd.conf file and In "Section 3: Virtual Hosts" add the following lines:
NameVirtualHost 127.0.0.2:80
<VirtualHost 127.0.0.2>
DocumentRoot "/srv/www/validator"
ServerName validator.example.org
<Directory "srv/www/validator">
Order allow,deny
Allow from all
Options ExecCGI
AllowOverride None
AddHandler cgi-script .cgi
AddCharset utf-8 .html
</Directory>
</VirtualHost>
Make sure that you have changed the DocumentRoot name to your DocumentRoot name.
For further details see Vhosts configuration.
Apache Configuration
Add the contents of the /usr/local/validator/httpd/conf/validator-httpd.conf file into Apache httpd.conf file and make the following changes:
ScriptAlias /check "/srv/www/validator/check"
ScriptAliasMatch /feedback(\.html)? "/srv/www/validator/sendfeedback.pl"
Alias /w3c-validator/ "/srv/www/validator/"
# Example httpd.conf snippet for W3C Markup Validation Service # Note that this is not a complete server configuration file, but contains # only the validator-specific part. # # You can use the Include directive for including this in your main httpd.conf. # # The values below assume that you have the validator files in # /usr/local/validator. If not, tune them according to your setup. # # Note: running the validator under mod_perl is not supported at the moment. ScriptAlias /check "/srv/www/validator/check" ScriptAliasMatch /feedback(\.html)? "/srv/www/validator/sendfeedback.pl" # This is the directory where you have the validator's *.html, *.css etc files. Alias /w3c-validator/ "/srv/www/validator/" <Directory "/usr/local/validator/htdocs"> Options IncludesNOEXEC Indexes MultiViews AllowOverride None AddHandler server-parsed .html AddCharset utf-8 .html </Directory> <IfModule mod_headers.c> <Directory "/usrv/local/validator/images"> Header set Cache-Control "max-age=604800" </Directory> </IfModule>
Hosts Configuration
Add the following lines to your etc/hosts file:
www.surveymain.com localhost www.surveymain.com www.example.org 127.0.0.2 validator.example.org
Validator Configuration
You may need to make changes to your etc/w3c/validator.conf as follows:
Allow Private IPs = yes
Home Page = http://validator.example.org/
#
# Main Configuration File for the W3C Markup Validation Service.
#
# $Id: validator.conf,v 1.24 2005-07-08 08:31:09 ot Exp $
#
# See 'perldoc Config::General' for the syntax, and be aware that the
# 'SplitPolicy' is 'equalsign', ie. keys and values are separated by '\s*=\s*',
# and that 'InterPolateVars' is in effect.
#
#
# Base Path for Markup Validator files.
#
# You MUST set these unless you use the default locations for the files.
# e.g. the config files in "/etc/w3c/" and everything else in
# "/usr/local/validator/".
#
# Make sure all file paths below do NOT end with a slash
<Paths>
#
# Base path. Defaults to the value of the W3C_VALIDATOR_HOME environment
# variable or /usr/local/validator if the variable does not exist.
Base = /usr/local/validator
#
# Location of template files
Templates = $Base/share/templates
<SGML>
#
# The SGML Library Path.
Library = $Base/htdocs/sgml-lib
#
# The SGML Parser to use. Defaults to /usr/bin/onsgmls.
Parser = /usr/bin/onsgmls
</SGML>
</Paths>
#
# This controls whether the debugging options are allowed to be enabled.
Allow Debug = yes
#
# This lets you permanently enable the debugging options. Can be overridden
# with CGI options (unlike "Allow Debug" above).
Enable Debug = no
#
# Whether private RFC1918 addresses are allowed.
#Allow Private IPs = no
Allow Private IPs =yes
#
# Whether the (highly experimental!) SOAP support should be enabled.
Enable SOAP = no
#
# Whether the validator will check its own output.
# 0 means it will refuse to check its own output, 1 means it will but it will
# refuse to check the results of it checking itself. Etc.
Max Recursion = 0
#
# Protocols the validator is allowed to use for retrieving documents.
# The default is to allow http and https.
<Protocols>
Allow = data,http,https
</Protocols>
#
# Email address of the maintainer of this service.
Maintainer = www-validator@w3.org
#
# The "Home Page" for the service. Make sure this ends with a slash.
#Home Page = http://validator.w3.org/
Home Page = http://validator.example.org/
#
# Base URI for the Element Reference.
Element Ref URI = http://www.htmlhelp.com/reference/html40/
#
# Mapping tables etc...
#
#
# Maps element names to URLs (cf. "Element Ref URI" above).
<Elements>
Include eref.cfg
</Elements>
#
# Main document Type Registry; contains all information on the types
# of documents we support and how they are processed.
<Types>
Include types.conf
</Types>
#
# Mapping of charset names to their IANA names and how iconv(3) knows them.
<Charsets>
Include charset.cfg
</Charsets>
#
# Map MIME Media Type to Parse Mode mapping.
<MIME>
text/xml = XML
image/svg = XML
image/svg+xml = XML
application/smil = XML
application/xml = XML
text/html = TBD
text/vnd.wap.wml = XML
application/xhtml+xml = XML
application/mathml+xml = XML
</MIME>
#
# Source for the "Tip of The Day" blurbs.
<Tips>
Include tips.cfg
</Tips>
Test the installation
Restart Apache.
Point your browser at the new site.
Check the error log.
For more details see: The general Installation guide.
Problems encountered
I had to change the ScriptAlias to:
ScriptAlias /check "/srv/www/validator/check"
ScriptAliasMatch /feedback(\.html)? "srv/www/validator/feedback.pl"
Resources
- W3C validator information page
- Linux (Slackware) by Nick Talbott
- Linux From Scratch
- Mac OS X and OS X Server at the Apple Developer Connection,
- Mac OS X and OS X Server by Stephen Yoch,
- Windows, by David Tibbe


