namazu UTF-8 + apache EUC-JP

ちょいと全文検索をサイトに組み込み時に填ったので、記録しておく。

会社のWEBサイトは、さくらインターネットでスペースを借りているわけですが、apacheでEUC-JPな設定になっておりまして、UTF-8を使ったページを全文検索の対象になるようnamazuをユーザーフォルダにインストールしました。

mknmzを動かしインデックスを作成し、index.cgiを設置、全文検索出来ると確認したわけです。が、mknmzで作成されるテンプレートの文字コードは、EUC+LFになっておりまして、全く問題ないわけです。当たり前ですが・・・

namazuが動く事を確認したあと、既存のページに検索フォームを設置し確認したところ、文字化けで日本語が一切検索対象に出来ない事が判明。

ググった結果、文書の文字コードがUTF-8の場合、NKFのバージョンを2.0.4以上にすればOKとのこと。
<blockquote>NKFは2.0.4からUTF-8に対応</blockquote>
phpで検索語句をラッピングしてnamazu.cgiに渡すようにすればOKとのことで、

<strong>post.php</strong>
<blockquote>&lt;?php
$url = ‘http://MySiteDomain/namazu.cgi’;
$query = $_POST[‘query’];
$whence = ‘0’;
$lang = ‘ja’;
$max = ’20’;
$query = rawurlencode(mb_convert_encoding($query, ‘EUC-JP’, ‘auto’));
header(“Location: $url?query=$query&amp;whence=$whence&amp;max=$max&amp;lang=$lang”);
exit;
?&gt;</blockquote>
<strong>検索フォーム</strong>
<blockquote>&lt;form method=”post” action=”./post.php”&gt;
&lt;p&gt;&lt;label&gt;サイト内Namazu検索
&lt;input type=”text” name=”query” accesskey=”q” tabindex=”1″ size=”20″ value=”” /&gt;&lt;/label&gt;
&lt;input type=”submit” name=”submit” tabindex=”2″ accesskey=”s” value=”検索” /&gt;
&lt;/p&gt;
&lt;/form&gt;</blockquote>

LS-GL / HS-DHGL

LS-GL/HS-DHGL  HackKitでdebianのインストール純正LS-GLに新しいディスクをUSBで接続する。
オートマウントが働いて自動マウントするので、umountしておく。/dev/sdbとして認識

kernel: scsi3 : SCSI emulation for USB Mass Storage devices
kernel:   Vendor: Generic   Model: External          Rev: 1.04
kernel:   Type:   Direct-Access                      ANSI SCSI revision: 04
kernel: SCSI device sdb: 1953525168 512-byte hdwr sectors (1000205 MB)
kernel: sdb: Write Protect is off
kernel: SCSI device sdb: 1953525168 512-byte hdwr sectors (1000205 MB)
kernel: sdb: Write Protect is off
lsbox kernel:  sdb:
lsbox kernel: sd 3:0:0:0: Attached scsi disk sdb
lsbox kernel: sd 3:0:0:0: Attached scsi generic sg1 type 0

fdiskする。

sdb1 200M /boot
sdb2 40G /
sdb3 512M /swap
sdb4 残り全部 /mnt

HackKitインストールの準備をする。

/mnt/disk1/share/debian/LS-GL_hackkit_2.10.sh
/mnt/disk1/share/debian/LS-GL_hackkit_2.10.tar.gz

vi LS-GL_hackkit_2.10.sh

ADDRESS=192.168.0.201
NETWORK=192.168.0.0
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
GATEWAY=192.168.0.254
NAMESERVER=192.168.0.30
HOSTNAME=TVBOX

MOUNTPOINT=/mnt/debinst
WORK=/mnt/disk1/share/debian

# time sh LS-GL_hackkit_2.10.sh
real    4m5.068s
user    1m6.510s
sys    0m28.820s

インストールはこれで完了である。chrootして新しいディスクのシステムに入って環境設定してもいいし、LS-GLに新しいディスクをつなぎ替えて起動し、telnetで接続してもいいけど、今回はtelnetで構築することにする。

guestでログイン後、su

client $ telnet tvbox
tvbox $ su
tvbox # passwd
tvbox # useradd hoge
tvbox # passwd hoge
tvbox # mkdir /home/hoge
tvbox # chown :hoge:hoge
tvbox # exit
tvbox $ exit
$ telnet tvbox
# su
# deluser guest

# date

# apt-get update
# apt-get upgrade

ntpd

# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
server ntp.ring.gr.jp
server ntp.ring.gr.jp
server 192.168.0.53

# pool.ntp.org maps to more than 300 low-stratum NTP servers.
# Your server will pick a different set every time it starts up.
#  *** Please consider joining the pool! ***
#  *** <http://www.pool.ntp.org/join.html> ***
#server 0.debian.pool.ntp.org iburst
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst

# /etc/init.d/ntp restart

sshd

aptでインストール

samba

aptでインストール

smartmontools

# apt-get install smartmontool
# smartctl -d marvell -A /dev/sda
smartctl version 5.36 [armv4l-unknown-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate     0x000f   200   200   051    Pre-fail  Always       –       0
3 Spin_Up_Time            0x0003   183   178   021    Pre-fail  Always       –       7841
4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       –       50
5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       –       0
7 Seek_Error_Rate         0x000e   200   200   051    Old_age   Always       –       0
9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       –       1049
10 Spin_Retry_Count        0x0012   100   253   051    Old_age   Always       –       0
11 Calibration_Retry_Count 0x0012   100   253   051    Old_age   Always       –       0
12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       –       50
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       –       44
193 Load_Cycle_Count        0x0032   198   198   000    Old_age   Always       –       6993
194 Temperature_Celsius     0x0022   111   104   000    Old_age   Always       –       41
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       –       0
197 Current_Pending_Sector  0x0012   200   200   000    Old_age   Always       –       0
198 Offline_Uncorrectable   0x0010   100   253   000    Old_age   Offline      –       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       –       0
200 Multi_Zone_Error_Rate   0x0008   100   253   051    Old_age   Offline      –       0

LS-GL/HS-DHGL

LS-GL/HS-DHGL  HackKitでdebianのインストール純正LS-GLに新しいディスクをUSBで接続する。
オートマウントが働いて自動マウントするので、umountしておく。/dev/sdbとして認識

kernel: scsi3 : SCSI emulation for USB Mass Storage devices
kernel:   Vendor: Generic   Model: External          Rev: 1.04
kernel:   Type:   Direct-Access                      ANSI SCSI revision: 04
kernel: SCSI device sdb: 1953525168 512-byte hdwr sectors (1000205 MB)
kernel: sdb: Write Protect is off
kernel: SCSI device sdb: 1953525168 512-byte hdwr sectors (1000205 MB)
kernel: sdb: Write Protect is off
lsbox kernel:  sdb:
lsbox kernel: sd 3:0:0:0: Attached scsi disk sdb
lsbox kernel: sd 3:0:0:0: Attached scsi generic sg1 type 0

fdiskする。

sdb1 200M /boot
sdb2 40G /
sdb3 512M /swap
sdb4 残り全部 /mnt

HackKitインストールの準備をする。

/mnt/disk1/share/debian/LS-GL_hackkit_2.10.sh
/mnt/disk1/share/debian/LS-GL_hackkit_2.10.tar.gz

vi LS-GL_hackkit_2.10.sh

ADDRESS=192.168.0.201
NETWORK=192.168.0.0
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
GATEWAY=192.168.0.254
NAMESERVER=192.168.0.30
HOSTNAME=TVBOX

MOUNTPOINT=/mnt/debinst
WORK=/mnt/disk1/share/debian

# time sh LS-GL_hackkit_2.10.sh
real    4m5.068s
user    1m6.510s
sys    0m28.820s

インストールはこれで完了である。chrootして新しいディスクのシステムに入って環境設定してもいいし、LS-GLに新しいディスクをつなぎ替えて起動し、telnetで接続してもいいけど、今回はtelnetで構築することにする。

guestでログイン後、su

client $ telnet tvbox
tvbox $ su
tvbox # passwd
tvbox # useradd hoge
tvbox # passwd hoge
tvbox # mkdir /home/hoge
tvbox # chown :hoge:hoge
tvbox # exit
tvbox $ exit
$ telnet tvbox
# su
# deluser guest

# date

# apt-get update
# apt-get upgrade

ntpd

# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
server ntp.ring.gr.jp
server ntp.ring.gr.jp
server 192.168.0.53

# pool.ntp.org maps to more than 300 low-stratum NTP servers.
# Your server will pick a different set every time it starts up.
#  *** Please consider joining the pool! ***
#  *** <http://www.pool.ntp.org/join.html> ***
#server 0.debian.pool.ntp.org iburst
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst

# /etc/init.d/ntp restart

sshd

aptでインストール

samba

aptでインストール

smartmontools

# apt-get install smartmontool
# smartctl -d marvell -A /dev/sda
smartctl version 5.36 [armv4l-unknown-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate     0x000f   200   200   051    Pre-fail  Always       –       0
3 Spin_Up_Time            0x0003   183   178   021    Pre-fail  Always       –       7841
4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       –       50
5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       –       0
7 Seek_Error_Rate         0x000e   200   200   051    Old_age   Always       –       0
9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       –       1049
10 Spin_Retry_Count        0x0012   100   253   051    Old_age   Always       –       0
11 Calibration_Retry_Count 0x0012   100   253   051    Old_age   Always       –       0
12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       –       50
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       –       44
193 Load_Cycle_Count        0x0032   198   198   000    Old_age   Always       –       6993
194 Temperature_Celsius     0x0022   111   104   000    Old_age   Always       –       41
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       –       0
197 Current_Pending_Sector  0x0012   200   200   000    Old_age   Always       –       0
198 Offline_Uncorrectable   0x0010   100   253   000    Old_age   Offline      –       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       –       0
200 Multi_Zone_Error_Rate   0x0008   100   253   051    Old_age   Offline      –       0

analog

2003/06/16

社内のwebサーバーのログ収集
環境:VineLinux 2.6r1+α

VPN(PPTP)導入時にkernel makeしているが、
# apt-get update
# apt-get upgrade
で最新版にする。


事前準備

インストール先は、一般ユーザーのbinディレクトリの中にする

http://www.analog.cx/download.html から最新版を持ってくる(analog-5.32.tar.gz [2003-06-16現在])

  • source の取得・展開
    $ wget http://www.analog.cx/analog-5.32.tar.gz
    $ tar zxvf tar zxvf analog-5.32.tar.gz
    $ cd analog-5.32
  • make しる
    設定は、analog.cfgで行うので、Makefileはさわらない
    $ make
  • analog.cfg の設定
    locateなどを使って、access_logの場所を調べておく
    $ locate access_log
    設定はこんな感じ
    —————————————————————-
    /var/log/httpd/access_log
    LOGFILE /var/log/httpd/access_log
    OUTFILE index.html
    HOSTNAME “[host.hoge.org]”
    HOSTURL http://host.hoge.org/
    LANGUAGE JAPANESE
    LANGFILE lang/jpe.lng
    DESCFILE lang/jpedesc.txt
    DOMAINSFILE lang/jpedom.tab
    —————————————————————-
  • anlgform.pl の設定
    analogのインストール先は、/home/hoge/bin/httpd_log とした
    perl の場所も確認しておいて環境に合わせて変更する
    @forbiddenの前あたりに一行付け足す。
    $analog = ‘/home/hoge/bin/httpd_log/analog’;
    最後の「;」を忘れない様に
  • jpeform.html の設定
    こちらは2カ所変更する
    jpeform.html は、langディレクトリに入ってます
    > <h1><!– img src=”/images/analogo.gif” alt=”” –>
    > <!– form action=”/cgi-bin/anlgform.pl” method=”POST” –>
    この2行を自分の環境に合わせて書き換える
  • ファイルの設置(インストール)
    mkdir -p /home/hoge/bin/httpd_log
    cp -R analog analog.cfg anlgform.pl ./lang ./images /home/hoge/bin/httpd_log
  • 完了…そしてcron
    自動運転 cronに好きな様に登録するもよし、formから随時作成するもよし
  • 文字化け対策として非常に参考になるでしょう
    postanalog

vpn

2003/05/07
Vine2.6r1 baseにVPNを構築
http://planetmirror.com/pub/mppe/
http://public.planetmirror.com/pub/mppe/linux-2.4.19-openssl-0.9.6b-mppe.patch.gz
のパッチをカーネルに当てる。
kernel2.4.20でも問題なく当たる。

# zcat linux-2.4.19-openssl-0.9.6b-mppe.patch.gz | patch -p1

テスト用のカーネルなので、Vineの.configを使う

# cp configs/kernel-2.4.20-i686.config ./.config
# make menuconfig

いらないのははずしておくと、makeする時間の短縮になる
moduleをインストールするまえに、/lib/modules/(version)をrenameしておく方がいいのかも

# mv /lib/modules/2.4.20-0vl29.1 /lib/modules/2.4.20-0vl29.1.org

# make dep
# make clean
# make bzImage
# make modules
# make modules_install

# /sbin/installkernel 2.4.20-vpn arch/i386/boot/bzImage System.map

liloの編集
—————————————————
image=/boot/vmlinuz-2.4.20-vpn
label=linux
read-only
root=/dev/hda6
—————————————————
# /sbin/lilo

再起動後、/etc/modules.confは以下のようになっていたのを、修正

/etc/modules.conf修正前
—————————————————
alias ppp-compress-18 ppp_mppe
alias ppp-compress-21 bsd_comp
alias ppp-compress-24 ppp_deflate
alias ppp-compress-26 ppp_deflate
alias ppp ppp_generic
alias char-major-108 off # This will be different for 2.3.x kernels
alias net-pf-47 ip_gre
—————————————————

/etc/modules.conf修正後
—————————————————
alias ppp ppp_generic
alias char-major-108 ppp_generic
alias tty-ldisc-3 ppp_async
alias tty-ldisc-14 ppp_synctty
alias ppp-compress-18 ppp_mppe
alias ppp-compress-21 bsd_comp
alias ppp-compress-24 ppp_deflate
alias ppp-compress-26 ppp_deflate
alias net-pf-47 ip_gre
—————————————————

モジュールの依存関係の更新をする
# depmod -a

必要に応じて、パケットフォワードの設定をする
/etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 1

pppとpptpのインスト&設定
バイナリを持ってきて、rpmでぶち込む
http://planetmirror.com/pub/mppe/
http://public.planetmirror.com/pub/mppe/ppp-2.4.1-3mppe.i386.rpm
http://public.planetmirror.com/pub/mppe/pptpd-1.1.3-1.i386.rpm

pppを入れる前に、vine製のpppをrpm -e しておく

# rpm -qa|grep ppp
ppp-2.4.1-0vl1
rp-pppoe-3.5-0vl1
rp-pppoe-gui-3.5-0vl1
# apt-get remove ppp
で、3つともremove

rpmで2つのバイナリをインストール
あとは、設定ファイルを編集するだけ

/etc/pptpd.conf
—————————————————
speed 115200
option /etc/ppp/options.pptpd
debug
localip 192.168.0.31-33
remoteip 192.168.0.34-36
#ipxnets 00001000-00001FFF
# TAG: listen
#listen 192.168.0.1
pidfile /var/run/pptpd.pid
—————————————————

/etc/ppp/options.pptpd
—————————————————
## CHANGE TO SUIT YOUR SYSTEM
lock

## turn pppd syslog debugging on
debug

## change ‘pptpd’ to whatever you specify as your server name in chap-secrets
#name in chap-secrets
name karn.myftp.org

proxyarp

# This option applies if you use ppp with chapms-strip-domain patch
#chapms-strip-domain

+chap
# These options apply if you use ppp with mppe patch
# NB! You should also apply the ChapMS-V2 patch
-chap
-chapms
+chapms-v2
mppe-128
mppe-stateless

# These options will tell ppp to pass on these to your clients
# To use ms-dns or ms-dns in options.pptpd it must exist in /etc/resolv.conf
ms-wins 192.168.0.30
#ms-dns your.server.here
—————————————————

/etc/chap-secrets
—————————————————
ユーザー名 サーバ名 “パスワード” IPアドレス
hoge karn.myftp.org “passwd” *
—————————————————

GW TCP/1723をVPN鯖に向ける