LoginSignup
2
1

More than 5 years have passed since last update.

httpd.confでのCGIの実行設定

Posted at

CGIプログラムの置き場所を/cgi-bin/に絞る場合

下記ディレクティブをhttpd.confに追記すればOK

httpd.conf
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

CGIプログラムの置き場所を絞らない場合

上記設定に加えて、AddHandlerとExecCGIを設定する

AddHandler

apacheに特定拡張子で作成されたファイルをcgi-scriptとして認識させる
これで、対象拡張子を持つファイルをCGIプログラム扱いできる
AddHandler cgi-script .cgi .pl

ExecCGI

CGIの使用を許可するディレクティブ内で、下記設定を追加する
Options ExecCGI
これで、対象ディレクティブでは(/chi-bin/でなくても)CGIスクリプトの実行が可能になる。

以下は/bbs/にCGIプログラムを配置する場合の設定

httpd.conf
<Directory "/var/www/bbs">
    AllowOverride None
    Options ExecCGI
    Require all granted
</Directory>
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1