httpサーバ「Apache」は,標準ではCGIとSSI共に動作しないようになっている。有効にさせるには,次の手順でhttpd.confの大まかに3つの個所に変更を加えよう。下の2つは行頭のコメント「#」を取るだけでも構わない。
# vi /etc/httpd/conf/httpd.conf # This should be changed to whatever you set DocumentRoot to. <Directory "/home/httpd/html"> Options Indexes Includes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> 〜中略〜 # AddHandler: allows you to map certain file extensions to "handlers", AddHandler cgi-script .cgi 〜中略〜 # To use server-parsed HTML files AddType text/html .shtml AddHandler server-parsed .shtml |
中ほどの個所「AddHandler: allows you to...」では,CGIを実行可能な拡張子を設定している。ここでは「.cgi」という拡張子であることが分かるだろう。また,一般的な「.pl」も加えておいてもよいだろう(.cgiの後に半角スペースに続けて.plを記述する)。
最後の個所「To use server-parsed HTML files」ではSSIを実行可能なファイルの拡張子を指定している。ここでは,標準のまま「.shtml」の拡張子の時に実行するようにしているが,これを「.html」に変更しても構わない。
ただし,この設定にするとSSIが含まれていないhtmlファイルでも実行するための判別負荷がかかるためパフォーマンスを重視する環境では注意が必要だ。
Copyright © ITmedia, Inc. All Rights Reserved.