seckie's programming memo

プログラミングするにあたって調べたことなどのメモ。たまにひどい英語で書く。

MAMP+VirtualHost環境でValidator S.A.Cを使う

MacApacheをそのまま使う(&VirtualHost無し)なら以下のやり方でそのまま動く。 http://habilis.net/validator-sac/#advancedtopics

が、自分の環境は MAMP+VirtualHost 環境なので以下のようなやり方をした。

まず公式の通り、設定ファイルをコピー。

$ cd /Applications/Validator-SAC.app/Contents/Resources
$ sudo cp validator/httpd/conf/validator-SAC.conf /Applications/MAMP/conf/apache/extra

コピーした validator-SAC.conf の中身を以下のように書き換えた。

#                                                                -*- apache -*-
# Leopard (10.5) Apache 2 configuration for Validator S.A.C. installed in /Applications
<Directory "/Applications/Validator-SAC.app/Contents/Resources/validator/httpd/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
<Directory '/Applications/Validator-SAC.app/Contents/Resources/validator/htdocs/'>
  Options               IncludesNOEXEC Indexes MultiViews
  AllowOverride         None
  Order allow,deny
  Allow from all
  AddHandler            server-parsed .html
  AddCharset            utf-8         .html
</Directory>

<IfModule mod_headers.c>
<Directory '/Applications/Validator-SAC.app/Contents/Resources/validator/htdocs/images'>
  Header set            Cache-Control "max-age=604800"
</Directory>
</IfModule>

<VirtualHost *:80>
    DocumentRoot '/Applications/Validator-SAC.app/Contents/Resources/validator/htdocs/'
    ServerName validator.localhost

    # First, tell httpd that check_wrapper.sh and sendfeedback_wrapper.sh are CGI scripts.
    ScriptAlias      /check   '/Applications/Validator-SAC.app/Contents/Resources/validator/httpd/cgi-bin/check_wrapper.sh'
    ScriptAliasMatch /feedback(\.html)? '/Applications/Validator-SAC.app/Contents/Resources/validator/httpd/cgi-bin/sendfeedback_wrapper.sh'

    # This is the directory where you have the validator's *.html, *.css etc files.
    Alias /   '/Applications/Validator-SAC.app/Contents/Resources/validator/htdocs/'

    # Advertise the service on Bonjour/Rendevous
    # ここをコメントアウトしないと動かない
#     RegisterResource "W3C Validator S.A.C." /
</VirtualHost>

そして httpd.conf から Include する。

$ sudo vim /Applications/MAMP/conf/apache/httpd.conf

# 末尾に追加
Include /Applications/MAMP/conf/apache/extra/validator-SAC.conf

hosts ファイルに設定を追加するのも忘れてはいけない。

$ sudo vim /etc/hosts

# 末尾に追加
127.0.0.1  validator.localhost

MAMP apache を再起動したら http://validator.localhost/ で見れるようになる。