HOWTO: Painless markup validation with Opera and Ubuntu

Opera has a rather neat feature for validating markup. By pressing Ctrl-Alt-V or if you right click on a page and select “Validate”, you send off the data to the W3C validator.
However, if you ever work offline, or you, like me, work with markup that shouldn’t be transmitted to external sources, or if you want a validator that responds immediatly, there is a better solution: Installing the validator locally. Here’s how to install the validator locally in Ubuntu, and then configuring Opera to use the locally installed validator instead of the external one.
h3. Installing Apache and the validator
The first thing you’ll have to do, is to install Apache and the w3c markup validator on your local system. Type the following in a terminal:

sudo apt-get install apache2 w3c-markup-validator

apt should take care of all needed dependencies for you. When installation is finished, continue to the next step:
h3. Configuring Apache
(Updated: The previous version edited /etc/apache2/apache2.conf directly, which is a bit more messy if you feel like disabling the service later)
Next, you will have to add the validator to your Apache configuration by adding the validator configuration as a virutal site:

sudo gedit /etc/apache2/sites-enabled/validator.conf

When you have the file open in gedit, insert the following into the file:
bc.. ScriptAlias /w3c-markup-validator/check /usr/lib/cgi-bin/check
ScriptAlias /w3c-markup-validator/checklink /usr/lib/cgi-bin/checklink
Alias /w3c-markup-validator /usr/share/w3c-markup-validator/html

Options +Includes +MultiViews
AddHandler server-parsed .html

p. Save and close the file. To start the validator, you now have to restart apache. Again, by going to the terminal:

sudo apache2ctl restart

Verify that you have the web server and the validator running by visiting http://127.0.0.1/w3c-markup-validator/
h3. Configuring Opera
The final step is configuring Opera. Go to the Opera configuration editor: opera:config#UserPrefs|ValidationURL (clicking this link should be just fine). Replace the contents of the input field Validation URL, that has the following default content …

http://validator.w3.org/check

… with

http://127.0.0.1/w3c-markup-validator/check

Now, click “Save” in the configuration editor, and close the configuration page. When you now press Ctrl-Alt-V when visiting a page, Opera will now open the validator on your local system, hopefully saving you some time in the process.

11 Comments

  1. Stahn

     /  2006-10-03

    Sorry for being a little offtopic, but do you have a tutorial/manual/whatever for doing this with Windows XP?

  2. Grah

     /  2006-10-03

    @Stahn: I guess this would involve installing Ubuntu first 😉
    Jokes aside, from what I know, one can setup Apache on XP with XAMPP. Once installed, the steps should be the same (but it is _quite_ likely that I’m wrong).

  3. Jad

     /  2006-10-03

    Cool!
    Also user could add the validation URL into firefox Web developer extension.

  4. It’s a pity that their CSS validator isn’t available as a standalone application as well.

  5. Stahn: I don’t use Windows, so, no. But W3C has a “guide for installing the validator on Windows”:http://validator.w3.org/docs/install_win.html

  6. @Alexey:
    The css validator seems to be avaiable via CVS at
    http://jigsaw.w3.org/css-validator/DOWNLOAD.html

  7. Stahn

     /  2006-10-05

    Hmm, uses Perl… tricky =P I have to install it anyways, so I’ll give it a try later.
    Thank you everyone =)

  8. Asbjørn Ulsberg

     /  2006-10-09

    I’ve been trying to get the W3C Validator to work on Apache 2.2 under Windows for 2 hours now, but it’s frikkin’ impossible. Apache 2.2 and ActiveState Perl was easy enough to get up and running, but installing and configuring the Validator is the biggest pile of stinking, non-working and half-assed operations I’ve ever seen.
    I know the best answer is to switch to Linux, but that’s just not even close to being an option in my current job. Well, not if I want to checkk e-mail, log on to the network, have access to the source control server, the development environment, etc, etc. And I kinda need all of that to do my job.
    So if anyone knows of a more pre-configured distribution of the W3C Validator for Windows, please leave a comment here, because the default distribution the W3C developers have cooked up really only works on Linux. I’m sure it’s possible to get up and running on Windows, but not within an acceptable time frame.

  9. Asbjørn: VMWare player and a preconfigured Ubuntu image, perhaps?

  10. Asbjørn Ulsberg

     /  2006-10-09

    Yes, that’s a possibility. To have to run a whole operating system inside Windows to get the W3C Validator to run seems a bit over the top to me, though. It’s just silly that it doesn’t work out of the box on Windows, imo.

  11. Yeah, I also need something for my Windows. But then, anyway, thanks for the link, man.