mod_python のインストール

mod_python をインストールして、forecastfox 日本語対応版で使用する天気予報を出力できるようにします。

takanori

forecastfox 日本語対応版 で使用している、 AccuWeather の天気を翻訳する proxy を入れるために、 mod_python をインストールします。

目次

mod_python インストール

mod_python download のページから mod_python-3.2.7.tgz をダウンロードしてインストールします。

インストールの手順は、apache の場所や apxs を configure が見つけられれば、以下の通り簡単です。

% tar xfz mod_python-3.2.7.tgz
% cd mod_python-3.2.7
% ./configure
% make
% su
% make install

私の環境では /usr/lib/apache2/modulesmod_python.so がインストールされます。

apache 2 で mod_python を読み込み[apache2]

apache 2 の設定ファイル /etc/apache2/conf/httpd.conf を開いて、下記の行を LoadModule が書いてあるところに追加します。

LoadModule python_module modules/mod_python.so

翻訳フィルタのインストール[filter]

翻訳フィルタ weather.py を適当なディレクトリに作成します。 ここでは /home/hoge/python/ 以下に作成したことにします。

次に、apache 2 の設定ファイル /etc/apache2/conf/httpd.conf を開いて、 /adcbin という URL が要求されたら翻訳フィルタ経由で結果を返すよう設定を下記のように記述します。:

    RewriteEngine On
    RewriteRule ^/adcbin/(.*) http://forecastfox.accuweather.com:80/adcbin/$1 [L,P]

    PythonPath "sys.path+['/home/hoge/python']"
    PythonOutputFilter weather
    <Location /adcbin>
      SetOutputFilter weather
    </Location>

あとは、apache 2 に設定ファイルを再読み込みさせれば終了です。

# /etc/init.d/apache2 configtest
Syntax OK
# /etc/init.d/apache2 reload
httpdを再読み込み中:                                       [  OK  ]