analog - インストール
- はじめに
- analogの構築について解説します。
今回はグラフを出力させるために、予めGD,JPEG,PNGライブラリがインストールされてあり、
解析結果を/usr/local/apache/htdocs/analogへ出力する事を前提としています。
- 用意するもの
- analog-6.0.tar.gz
- 公式サイト
http://www.analog.cx/
- ダウンロードサイト
http://www.analog.cx/download.html
- コンパイル&インストール
% tar zxvf analog-6.0.tar.gz
% cd analog-6.0/src
% vi anlghead.h
--- anlghead.h.orig Tue Jan 4 01:26:55 2005
+++ anlghead.h Tue Jan 4 01:44:48 2005
@@ -24,19 +24,19 @@
#define ANLGHEAD_H
#ifndef HOSTNAME
-#define HOSTNAME "[my organisation]"
+#define HOSTNAME "[www.example.com]"
/* The name of your organisation or web server. This is used for printing
at the top of the output. */
#endif
#ifndef HOSTURL
-#define HOSTURL "none"
+#define HOSTURL "http://www.example.com/"
/* The URL of your host's home page, for linking to at the top of the
output; use "none" for no linking. */
#endif
#ifndef LOGFILE
-#define LOGFILE "logfile.log"
+#define LOGFILE "/usr/local/apache/logs/access_log"
/* The name of the default logfile. Can be a list, separated by commas
(but no spaces), and can include wild cards. */
#endif
@@ -47,7 +47,7 @@
#endif
#ifndef IMAGEDIR
-#define IMAGEDIR "images/"
+#define IMAGEDIR "/icons/"
/* URL of the directory where the images for the graphical reports live.
The URL can be absolute, or relative to the output page: e.g., just the
empty string "" for the same directory as the output page. */
@@ -72,7 +72,7 @@
#endif
#ifndef DEFAULTCONFIGFILE
-#define DEFAULTCONFIGFILE "analog.cfg"
+#define DEFAULTCONFIGFILE "/usr/local/etc/analog.conf"
/* The name of the default configuration file. */
#endif
@@ -93,7 +93,7 @@
directory. This may or may not work, so it's better to specify a location
explicitly here if you know where the files will be kept. */
#ifndef LANGDIR
-#define LANGDIR NULL
+#define LANGDIR "/usr/local/share/analog/"
#endif
/* Directory where the language files live. Actually, if this one is defined
to be NULL, they will be looked for inside the "lang" subdirectory of the
% vi anlghea2.h
--- anlghea2.h.orig Tue Jan 4 01:27:00 2005
+++ anlghea2.h Tue Jan 4 01:29:10 2005
@@ -412,7 +412,7 @@
OUT_NONE. */
#ifndef LANGUAGE
-#define LANGUAGE (ENGLISH)
+#define LANGUAGE (JAPANESE_EUC)
/* Default language for the output page:
ARMENIAN, BASQUE, BULGARIAN, BULGARIAN_MIK, CATALAN, SIMP_CHINESE (GB2312),
TRAD_CHINESE (Big5), CZECH, CZECH_1250, DANISH, DUTCH, ENGLISH, US_ENGLISH,
% vi Makefile
--- Makefile.orig 2004-09-26 00:32:10.251789000 +0900
+++ Makefile 2004-09-26 00:33:56.961371000 +0900
@@ -5,12 +5,12 @@
CC = gcc # which compiler to use: eg cc, acc, gcc. NB Different
# compilers need different CFLAGS, e.g., -O instead of -O2.
MAKE = make # which "make" to use
-CFLAGS = -O2 # options, e.g. for optimisation or ANSI compilation.
+CFLAGS = -O2 -I/usr/local/include -I/usr/sfw/include # options, e.g. for optimisation or ANSI compilation.
# HP/UX cc needs CFLAGS = -Aa (HP/UX 9) or -Ae (HP/UX 10)
# BeOS needs CFLAGS = -O2 -Wl,-L/boot/home/config/lib
# BS2000/OSD needs CFLAGS = -XLLML -XLLMK
# NeXTSTEP needs CFLAGS = -O2 -pipe -no-precomp
-DEFS = # any combination of -DNOPIPES -DNODNS -DNODIRENT -DNOGLOB ...
+DEFS = -DHAVE_GD -DHAVE_ZLIB # any combination of -DNOPIPES -DNODNS -DNODIRENT -DNOGLOB ...
# ... -DNOOPEN -DNOFOLLOW -DNOALARM -DNOGRAPHICS -DNOGMTIME ...
# ... -DEBCDIC -DUSE_PLAIN_SETJMP ...
# ... -DHAVE_GD -DHAVE_ZLIB -DHAVE_PCRE ...
@@ -29,7 +29,7 @@
#
OS = UNIX # Operating system: UNIX, DOS, WIN32, MAC, OS2, OSX, VMS
# RISCOS, BEOS, NEXTSTEP, MPEIX, BS2000, AS400, OS390
-LIBS = -lm # extra libraries needed; most platforms (but not OS X or BeOS)
+LIBS = -L/usr/local/lib -R/usr/local/lib -L/usr/sfw/lib -R/usr/sfw/lib -lgd -lpng -ljpeg -lresolv -lsocket -lnsl -lz -lm # extra libraries needed; most platforms (but not OS X or BeOS)
# need -lm LAST
# if you defined HAVE_GD above you also need -lgd -lpng -ljpeg -lz
# if you defined HAVE_ZLIB above you also need -lz
% make
% cd ..
% su
# cp analog /usr/local/bin
# cp analog.cfg /usr/local/etc/analog.conf
# cp -R lang /usr/local/share/analog
# cp analog.man /usr/local/man/man1/analog.1
# mkdir -p /usr/local/apache/htdocs/analog
# cp lang/jpeform.html /usr/local/apache/htdocs/analog/index.html
# cp images/* /usr/local/apache/icons
# cp anlgform.pl /usr/local/apache/cgi-bin
フォームコンテンツの修正
# vi /usr/local/apache/htdocs/analog/index.html
--- lang/jpeform.html 2003-03-23 22:56:59.000000000 +0900
+++ /usr/local/apache/htdocs/analog/index.html 2004-09-26 00:48:15.866908000 +0900
@@ -5,7 +5,7 @@
</head>
<body>
-<h1><!-- img src="/images/analogo.gif" alt="" -->
+<h1><img src="/icons/analogo.gif" alt="">
Analog フォーム・インタフェース</h1>
<!-- 以下を編集すること。anlgform.pl も編集する必要がある。 -->
@@ -14,28 +14,24 @@
<!-- 次に、サーバ内での anlgform.pl の正しい位置を反映するように編集して -->
<!-- 以下の行のコメントを削除しなさい。 -->
-<!-- form action="/cgi-bin/anlgform.pl" method="POST" -->
+<form action="/cgi-bin/anlgform.pl" method="POST">
<!-- 他の環境設定ファイルを以下で指定できる。 -->
-<!-- input type=hidden name="cg" value="/analog/other.cfg" -->
+<input type=hidden name="cg" value="/usr/local/etc/analog.cfg">
<!-- 多くのシステムでは、IMAGEDIR が /cgi-bin/ 中に無いようにしたいために、 --><!-- フォーム上の IMAGEDIR はコマンドライン上とは異なるようにしている。 -->
-<!-- input type=hidden name="IMAGEDIR" value="/images/" -->
+<input type=hidden name="IMAGEDIR" value="/icons/">
<!-- あるユーザの設定では、ログファイルは以下のようになるでしょう。 -->
-<!-- input type=hidden name="LOGFILE" value="/usr/local/apache/logs/access_log" -->
+<input type=hidden name="LOGFILE" value="/usr/local/apache/logs/access_log">
-<input type=hidden name="LANGUAGE" value="JAPANESE">
+<input type=hidden name="LANGUAGE" value="JAPANESE_EUC">
<!-- これらを編集した後、以下の赤で "強調" した行を削除して下さい。 -->
<hr>
<h2>1. レポートの選択</h2>
-<strong><font color=red>注意 : 以下の指示に従って環境を設定し終わるまで、
-このフォームは動かないでしょう。例えば、ボタンさえ現れないかもしれません。
-環境設定を終了した後、この文節を削除してください。<br>
-</font></strong>
<i>個々のレポートの詳細な意味については
<a href="http://www.analog.cx/">analog
CGIスクリプトの修正
# vi /usr/local/apache/cgi-bin/anlgform.pl
--- anlgform.pl.orig Mon Aug 19 11:00:46 2002
+++ anlgform.pl Mon Aug 19 11:01:07 2002
@@ -13,7 +13,7 @@
# 1) uncomment (remove everything before $analog) and edit one of the next two
# lines to give the location (full pathname) of the analog executable.
-# Unix: $analog = '/usr/local/etc/httpd/analog-5.24/analog';
+$analog = '/usr/local/bin/analog';
# Windows: $analog = 'C:\program files\analog 5.24\analog.exe';
# 2) If you're on Unix, edit the first line in this file to give the location
# of Perl (don't remove the #! though).
コンフィグレーション
# vi /usr/local/etc/analog.conf
--- ../analog.cfg Sun Dec 19 22:51:22 2004
+++ /usr/local/etc/analog.conf Tue Jan 4 02:00:04 2005
@@ -10,10 +10,10 @@
#
# If you need a LOGFORMAT command (most people don't -- try it without first!),
# it must go here, above the LOGFILE commands.
-LOGFILE logfile.log
+LOGFORMAT COMBINED
+LOGFILE /var/apache/logs/access_log
+OUTFILE /usr/local/apache/htdocs/analog/Report.html
+HOSTNAME "[www.example.com]"
# LOGFILE /old/logs/access_log.*
# OUTFILE Report.html
# HOSTNAME "[my organisation]"
@@ -104,3 +107,6 @@
TYPEALIAS .cfm ".cfm [Cold Fusion]"
TYPEALIAS .php ".php [PHP]"
TYPEALIAS .js ".js [JavaScript code]"
+
+LANGUAGE JAPANESE-UTF
+SEARCHCHARCONVERT ON
実行
- 出力方法は、analogコマンドを実行してコンテンツを作成する方法と、
ブラウザ上からHTMLコンテンツへアクセスし任意の結果をCGIから出力表示する2つの方法があります。
- コマンドライン
# /usr/local/bin/analog
上記コマンドを実行すると、デフォルトコンフィグレーション(/usr/local/etc/analog.cfg)の指定内容に従って、
下記URLコンテンツが作成されます。
http://www.example.com/analog/Report.html
なお、デフォルト以外のコンフィグや、解析結果の出力先を変更したい場合は、
下記のオプションを与えて実行します。
# /usr/local/bin/analog -G +g/usr/local/etc/my-analog.cfg +O/usr/local/apache/htdocs/sample.html
- フォームからのアクセス
直接下記URLへアクセスして、任意の結果を出力します。
http://www.example.com/analog/index.html
コマンドラインではグラフが付属したコンテンツが作成されますが、
フォームアクセスから作成する動的コンテンツにはグラフが付与されないので、
抽出目的に応じて使い分けると良いでしょう。