Skip to content

W3C Validator

W3C Validator Installation on CentOS 4.4

By: Max Hetrick
Last modified on:
11-02-2006 - Initial creation.

Printer friendly: http://www2.maxsworld.org/howtos/w3c_install.html

Do you get tired of going outside your network to validate to W3C? Don’t feel like wasting bandwith? If so, then this guide will show you how to set up a W3C Validator locally on an instance of Apache.

System/Dependencies

  • CentOS 4.4
  • OpenSP 1.5 (provided in package openjade)
  • Apache
  • Perl:
    • CGI
    • Config-General
    • HTML-Parser
    • HTML-Template
    • LWP UserAgent
    • Net-IP
    • Set-IntSpan
    • Text-Iconv
    • URI

Downloads

Installing Prerequisites

OpenSP 1.5

OpenSP provides the SGML (Standard Generalized Markup Language) which does a lot of the hard work behind validation. CentOS provides this package already within openjade. Let’s see if you have it installed. If you don’t have it installed, just install it through yum.

[root@desktop ~]# rpm -q openjade
openjade-1.3.2-14

If it’s missing:

[root@desktop ~]# yum install openjade

Installing Perl Dependencies

The next part deals with installing all the Perl dependencies. Now, you can actually do the installation two different ways. The first is to do go to Dag’s repo and find the RPMs, or the second, easiest, method is to install a bundled package from CPAN which contains the necessary packages.

[root@desktop ~]# perl -MCPAN -e shell

cpan shell — CPAN exploration and modules installation (v1.7601)
ReadLine support enabled

 cpan>install Bundle::W3C::Validator
<SNIP> tons of output
 

Note about Apache

I’ll only briefly mention Apache. If you need an Apache instance installed and configured, then I’d suggest looking for the Apache docs so you can set yourself up in a secure environment. If you’re only setting it up on your desktop/laptop and it’s not accepting remote incoming connections, or you have a secure internal network where you’re setting this up, then it’s not a big deal to do the following. Apache is pretty secure out of the box.

[root@desktop ~]# yum install httpd
[root@desktop ~]# vim /etc/httpd/conf/httpd.conf

# At least set your Servername and port you want to accept on
ServerName your_validator_server:80

[root@desktop ~]# chkconfig httpd on
[root@desktop ~]# httpd -t
Syntax ok

[root@desktop ~]# service httpd start

Now browse to http://localhost and you should see your CentOS test page.

Installing the W3C Validator Code

Download the stuff

You can install these items wherever you’d like, but I just go ahead and install them under Apache’s normal place of /var/www/html since they are going to be dished out across the browser anyways. You’ll need to download the code, unpack it, move a few things around, and change some permissions.

[root@desktop html]# wget http://validator.w3.org/validator.tar.gz
[root@desktop html]# wget http://validator.w3.org/sgml-lib.tar.gz
[root@desktop html]# tar -xzvf validator.tar.gz
[root@desktop html]# tar -xzvf sgml-lib.tar.gz
[root@desktop html]# rm -rf sgml-lib.tar.gz validator.tar.gz
[root@desktop html]# mv validator-0.7.3/ validator
[root@desktop html]# chown -R apache.apache validator/ # Or whomever you run Apache as
[root@desktop html]# cd validator/htdocs/
[root@desktop htdocs]# cp ../httpd/cgi-bin/check .
[root@desktop htdocs]# chmod 755 check

Configure the Validator File

Next you’ll need to actually configure some stuff.

[root@desktop htdocs]# mkdir /etc/w3c
[root@desktop htdocs]# cd /etc/w3c
[root@desktop w3c]# cp /var/www/html/validator/htdocs/config/* .
[root@desktop w3c]# vim validator.conf

# Line 24
Base = /var/www/html/validator

# Line 73
Maintainer = your_email_address.com

# Line 77
Home Page = http://localhost(servername)

Configure the Apache File

Now, you’ll need to edit the Apache file so that it knows how to dish content out and handle the CGI validation items. This requires adding a file to the /etc/httpd/conf.d/ directory. First make sure Apache is set to include the /conf.d directory.

[root@desktop w3c]# vim /etc/httpd/conf/httpd.conf
# Make sure this line exists
Include conf.d/*.conf

[root@desktop w3c]# vim /etc/httpd/conf.d/validator.conf
# This is the directory where you have the validator’s “check”
# script as well as its and *.html, *.css etc files.

<Directory /var/www/html/validator/htdocs>
    Options              ExecCGI IncludesNOEXEC Indexes MultiViews
    AllowOverride        None
    AddHandler           server-parsed .html
    AddCharset           utf-8         .html
</Directory>

# Tell httpd that “check” is a CGI script.

<Location “/validator/htdocs/check”>
    SetHandler           cgi-script
</Location>

Don’t forget to restart Apache after all of this.

[root@desktop w3c]# service httpd restart

Validate Away

That’s about all there is to it. Browse to your localhost/server and make sure the service is running. Now you can validate without having to go to W3C’s site all the time. Your validator will be located at: http://localhost(servername)/validator/htdocs/