AWStats

会社と家のサーバーはMacOSXである。
Webサービスをやっているのでログを自動的に視覚化してくれる”AWStats”をインストールしてある。
そのAWStatsを設定してから2ヶ月全然弄っていなかった「DNS逆引き」と「ドメインによる国分け」をやってみようと思った。

DNS逆引きをするとわけわかめなipアドレスをそのアドレスに対応した hogehoge.jp
のように分かりやすい名前に書き換えて表示してくれるのでStatsを取っている価値も上がるって訳で

ドメインによる国分けはこれをやると .jpは日本 .deはドイツ ってな感じにしてくれる。

まず、DNS逆引き。
AWStatsがどのconfファイルを使っていたか忘れてしまっていたのでcronファイルの中を確認した。

system(“/Library/WebServer/CGI-Executables/awstats/awstats.pl -config=conf名.local -output > /Library/WebServer/Documents/AWStats6.html”);

Confファイルの名前が分かった。
Confファイル183行目の DNSLookup= を1にすればいい。

これでDNS逆引き完了。

次はドメインによる国分けだが、これはちょっと面倒。
Geo::IPfreeというモジュールが必要になる。
CPANを使って手に入れる。

CPAN初級

ここをみてやってみる。OSXでもさほどかわらない。

#perl -MCPAN -e shell

で、上記のページを見て設定。っていってもEnterばっかし押しているような
最後の方でCPANサイトにつなぎに逝く

Fetching with Net::FTP:
ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY

Now we need to know where your favorite CPAN sites are located. Push
a few sites onto the array (just in case the first on the array won’t
work). If you are mirroring CPAN to your local workstation, specify a
file: URL.

First, pick a nearby continent and country (you can pick several of
each, separated by spaces, or none if you just want to keep your
existing selections). Then, you will be presented with a list of URLs
of CPAN mirrors in the countries you selected, along with previously
selected URLs. Select some of those URLs, or just keep the old list.
Finally, you will be prompted for any extra URLs — file:, ftp:, or
http: — that host a CPAN mirror.

(1) Africa
(2) Asia
(3) Central America
(4) Europe
(5) North America
(6) Oceania
(7) South America
Select your continent (or several nearby continents) [] 2
Sorry! since you don’t have any existing picks, you must make a
geographic selection.

(1) China
(2) Hong Kong
(3) India
(4) Indonesia
(5) Iran
(6) Israel
(7) Japan
(8) Malaysia
(9) Philippines
(10) Republic of Korea
(11) Russian Federation
(12) Saudi Arabia
(13) Singapore
(14) Taiwan
(15) Thailand
(16) Turkey
Select your country (or several nearby countries) [] 7
Sorry! since you don’t have any existing picks, you must make a
geographic selection.

(1) ftp://ftp.dti.ad.jp/pub/lang/CPAN/
(2) ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
(3) ftp://ftp.kddilabs.jp/CPAN/
(4) ftp://ftp.nara.wide.ad.jp/pub/CPAN/
(5) ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
(6) ftp://ftp.u-aizu.ac.jp/pub/CPAN
(7) http://ftp.cpan.jp/
Select as many URLs as you like (by number),
put them on one line, separated by blanks, e.g. ‘1 4 5’ [] 1 3 5 7

Enter another URL or RETURN to quit: []
New set of picks:
ftp://ftp.dti.ad.jp/pub/lang/CPAN/
ftp://ftp.kddilabs.jp/CPAN/
ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
http://ftp.cpan.jp/

まぁこんな感じでいいだろう。

===================会社の10.3の鯖ではこうなった===================
Bad luck… Still failed!
Can’t access URL ftp://ftp.perl.org/pub/CPAN/MIRRORED.BY.

とか出たりする。まさにBad luck!
なのでCPANサイトをgoogleして見つけたのを入力

Please enter your CPAN site: [] ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
Enter another URL or RETURN to quit: [] ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Enter another URL or RETURN to quit: []
New set of picks:
ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
ftp://ftp.dti.ad.jp/pub/lang/CPAN/
=========================================================

で、おわると

cpan> install Geo::IPfree

と入れてみる。するとするするとインストールされる。

なんて処理中にCPANのアップデートが出ているよ!と紹介してくれる。

There’s a new CPAN.pm version (v1.83) available!
[Current version is v1.76]
You might want to try
install Bundle::CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running…

ご丁寧にインストール方法も書いてある。

cpan> install Bundle::CPAN
LWP not available
Fetching with Net::FTP:
ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/authors/id/A/AN/ANDK/CPAN-1.83.tar.gz
CPAN: Digest::MD5 loaded ok

このあと延々と3回ぐらい同じ文字列の並びを見る。

CPAN: Term::ReadLine::Perl loaded ok
………………..
20 subroutines in Term::ReadLine redefined

cpan shell — CPAN exploration and modules installation (v1.76)
ReadLine support enabled

こうでるとアップデート終わりらしいので

cpan> reload cpan
………………………………………………………………………………………………………………………………………………………………………………………..
209 subroutines redefined
…………
12 subroutines redefined

リロードして続けてインストールしたい物が有れば入れてね。って感じ。

quitと入れればフツーのターミナルに戻れる。

cpan> quit
Lockfile removed.

CPANって楽ねぇ。

カテゴリー: 未分類 パーマリンク 拍手する

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です