foldrr's weblog

旧ブログ http://d.hatena.ne.jp/foldrr/

Windowsでshebangではなく拡張子とレジストリを使ってスクリプトを実行する

環境

問題

LinuxWindowsではスクリプトインタプリタのパスが違うためshebangを書き換える必要がある。
shebangの書き換えが面倒。

解決

ApacheのScriptInterpreterSourceを使うと、
shebangを無視して拡張子とレジストリを使ってスクリプトインタプリタを決定できる。

ScriptInterpreterSourceの設定

httpd.conf へ以下を記述する。

ScriptInterpreterSource registry

ExecCGI、AddHandlerの設定

httpd.confへ以下を記述する。

<Directory />
    :
    Options ... +ExecCGI
    AddHandler cgi-script ... .pl
    :
</Directory>

**Apacheの再起動
>|dosbatch|
C:\> net stop apache22
C:\> net start apache22

以上。