Installing the W3C Markup Validator on Mac OS X
For web developers it is often convenient to have local access to a markup validator. There are browser extensions like the excellent HTML Validator extension, but sometimes you want a standalone installation that can be used for batch testing or other tasks where a browser extension isn’t the best solution.
Several (many) years ago I posted a Quicklink about a document on Apple’s Developer site called Installing the W3C HTML Validator on Mac OS X, which obviously is useful for those of us who use Mac OS X. That document is still online, but the instructions there don’t seem to be quite up-to-date. Instead of following them, here’s what I did to get the W3C Markup Validator running on Mac OS X 10.6.
Note: These instructions assume that you’re quite comfortable with using the Terminal to poke around under the hood of your Mac and that you know a bit about configuring Apache, running commands as root, etc. If that doesn’t sound like you I would advise against trying this.
- Install the Developer Tools if they aren’t already installed (
Xcode.mpkgin the “Optional installs” folder on your Snow Leopard disc).
- Run Software Update to make sure everything is up-to-date.
- Install OpenSP as described in the W3C instructions.
Install the required Perl modules by running
install Bundle::W3C::Validatorthrough CPAN. Sit back and wait, because it’s going to take a while.
After plenty of downloading and compiling, the installation will most likely fail with the following message:
Failed during this command: PETDANCE/HTML-Tidy-1.54.tar.gz : make NO FLORA/perl-5.13.11.tar.gz : make NO isa perl
Fortunately Tidy is an optional module, and the essential parts seem to be installed before this error, so it doesn’t appear to be a showstopper.
I have no idea why the error occurs. I’ve tried installing this on at least three different Macs, including one with a completely clean install of OS X, and I get the same thing every time. It isn’t Mac OS X specific either – I get the same error on Ubuntu 10.10. If anyone knows what’s up with this and how to successfully install
Bundle::W3C::ValidatorI’d appreciate if you would let me know.
- Download and unpack the validator according to the W3C instructions, but put it in
~/Sites/validatorif you prefer) instead of in
Configure the validator. It should be enough to change the Base path in
/Library/WebServer/Documents/validator(or wherever you put the validator files) instead of
/usr/local/validator. Now calling the validator from the command line like this should work:
- If you’re reading this you’ll most likely have Apache enabled already. In case you don’t, start it either by enabling Web Sharing in the sharing control panel or typing
sudo apachectl startin the Terminal.
- In the directory where you unpacked the validator, find the file
/httpd/conf/httpd.confand copy it to the
- Edit the file, which should now be
/etc/apache2/other/httpd.conf, to replace all occurrences of
/Library/WebServer/Documents/validator(or wherever you put the files).
- Save the file and restart Apache by entering
sudo apachectl graceful.
With a bit of luck the validator should now be reachable at
To make it available at another URL, such as
http://validator.local/ or whatever you prefer, you’ll need to set up a virtual host in Apache and edit your
/etc/hosts file to add the name you want to use. I got this to work by copying the contents of
/etc/apache2/other/httpd.conf inside a VirtualHost directive in
/etc/apache2/users/username.conf and replacing all references to the
/w3c-validator/ directory with
<VirtualHost *:80> ServerName validator.local DocumentRoot /Users/username/Sites/validator/htdocs # Stuff from /etc/apache2/other/httpd.conf AliasMatch ^/+check(/+referer)?$ /Users/username/Sites/validator/cgi-bin/check AliasMatch ^/+feedback(\.html)?$ /Users/username/Sites/validator/cgi-bin/sendfeedback.pl … </VirtualHost>
With that in place, remove
/etc/apache2/other/httpd.conf and restart Apache again to make the changes take effect.
I’m posting this mostly as future reference for myself, but hopefully it will help others get the W3C Markup Validator up and running on Mac OS X as well.