Apache2 で、CGI ソースが表示されちゃう件の対応(Debian APT パッケージ編)[UNIXやLinux]
(2017-01-18 17:39:25) by shinoda


< ページ移動: 1 2 >

例えば、

http://www.exsample.com/cgi-bin/test.cgi

にアクセスすると、

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";

のような、CGI プログラムのソースが表示されてしまう。

さて、今回は Debian 系のパッケージ、いわゆる APT パッケージの Apache 2.4 を入れてみた。
RedHat 系世界の住民の俺から見ると、頭がおかしいんじゃないか?と思うような Apache 設定ファイルの構成である。

てか、俺は Apache に関しては「ソースからインストール派」なので、RPM パッケージの Apache の設定ファイル群にもイラっとさせられるんだけどね(笑)
まあ、この辺は宗教問題なのでこれ以上の言及は控えておきましょう(笑)

CGI プログラムのソースが表示されてしまう件に話を戻す。

まず、VirtualHost 設定の該当部分。

/etc/apache2/sites-available/www.exsample.com.conf の中に、

    ScriptAlias /cgi-bin/ "/usr/local/share/apache/cgi-bin/"

    <Directory "/usr/local/share/apache/cgi-bin">
        AllowOverride All
        Options +ExecCGI

        AddHandler cgi-script .cgi .pl

        Require all granted
    </Directory>

という記述あり。

なんか、ScriptAlias と Handler/ExecCGI の設定が二重にされてますけど(^^;
まあ、ScriptAlias してるんだから +ExecCGI は不要だと思うけど、現行、これで問題なく動いているので、とりあえずこれで良しとする(笑)

で、実際に CGI module を読み込んでるんかいな?と確認してみると、

# apache2ctl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 setenvif_module (shared)
 status_module (shared)

ありり?cgi_module がロードされてませんねえ。

# ls -la /etc/apache2/mods-available/cgi.load
-rw-r--r-- 1 root root 58  7月  6  2016 /etc/apache2/mods-available/cgi.load

cgi.load というファイルはあるので、こいつのシンボリックリンクを /etc/apache2/mods-enabled の下に作ってやる。

< ページ移動: 1 2 >


コメント投稿
次の記事へ >
< 前の記事へ
TOPへ戻る

Powered by
MT4i 3.0.8