通常,httpサーバ「Apache」の標準設定では,cgi-bin/と名づけられたディレクトリ下でのみCGIの実行を許可している。この設定は,httpd.confのなかで次の行に該当する。
# cat /usr/local/apache/conf/httpd.conf 〜中略〜 ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/" <Directory "/usr/local/apache/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> ※ディレクトリ構成は,特にパラメータを付加せずにソースからコンパイルした場合 |
標準では上記のように設定されているはずだ。「/usr/local/apache/cgi-bin/」ディレクトリ下での許可と,ScriptAliasでは「http://www.xxxxx.xxx/cgi-bin/」として「/usr/local/apache/cgi-bin/」ディレクトリ下を参照できるようにする設定だ。
通常の利用であれば,Perlスクリプトなどはcgi-bin/下に置くという基準の元使用すればよい。しかし,場合によっては任意のディレクトリ下にCGIの実行権を与えたいことがある。このような時には,次のように設定すればよい。
<Directory /usr/local/apache/htdocs/mrtg/nrg> Options +ExecCGI </Directory> |
httpd.confの中に上記のように記述すると,「http://www.xxxxx.xxx/mrtg/nrg/」とURL指定した際にでも,CGI実行が可能になる。
Copyright © ITmedia, Inc. All Rights Reserved.