2010年1月26日火曜日

キャッシュ及びアクセラレーターの比較

ベンチマークの比較です。
1.Apacheのキャッシュ機能を有効にした場合
2.PHPアクセラレーター(Xcache)を使った場合
3.XOOPSのキャッシュ機能を有効にした場合

サーバーを設置した場所とは全く別のサイトにCentOS環境を作成し、下記コマンドで比較した

[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
比較表
               Normal    Apache Cache On   PHP Xcache On
Time taken for tests:
1回目           28.921658     21.236325       12.785964
2回目           22.197865     24.28028       10.592108
3回目           29.399440     21.620780
Requests per second:
1回目           3.46         4.71           7.82
2回目           4.50         4.16           9.44
3回目           3.44         4.63

確かに速くなってます。
Xcacheでは体感上も確実に速度アップしました。
XOOPSのキャッシュ機能での比較はでは殆んど変化しなかったためここには載せていません。
設定が悪いのだろうか?

2010年1月25日月曜日

Xcacheを設定した場合のベンチマーク

1回目

[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

benchmarking xxxx-net.jp (be patient).....done

Server Software: Apache
Server Hostname: xxxx-net.jp
Server Port: 80
Document Path: /
Document Length: 0 bytes
Concurrency Level: 10
Time taken for tests: 12.785964 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 36400 bytes
HTML transferred: 0 bytes
Requests per second: 7.82 [#/sec] (mean)
Time per request: 1278.596 [ms] (mean)
Time per request: 127.860 [ms] (mean, across all concurrent requests)
Transfer rate: 2.74 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 51 360 899.9 64 3050
Processing: 403 817 411.1 757 4253
Waiting: 402 807 404.0 753 4252
Total: 467 1177 1042.7 812 4318
Percentage of the requests served within a certain time (ms)
50% 812
66% 857
75% 878
80% 915
90% 4029
95% 4050
98% 4068
99% 4318
100% 4318 (longest request)
2回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx-net.jp (be patient).....done

Server Software: Apache
Server Hostname: xxxx-net.jp
Server Port: 80

Document Path: /
Document Length: 0 bytes

Concurrency Level: 10
Time taken for tests: 10.592108 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 36400 bytes
HTML transferred: 0 bytes
Requests per second: 9.44 [#/sec] (mean)
Time per request: 1059.211 [ms] (mean)
Time per request: 105.921 [ms] (mean, across all concurrent requests)
Transfer rate: 3.30 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 53 92 283.0 63 2893
Processing: 439 843 1152.4 626 8477
Waiting: 438 835 1151.4 626 8477
Total: 505 936 1177.1 691 8542

Percentage of the requests served within a certain time (ms)
50% 691
66% 723
75% 757
80% 805
90% 1043
95% 1437
98% 8442
99% 8542
100% 8542 (longest request)
約二倍ほど速くなったかな??

PHP アクセラレーターXcacheのインストール

早速インストール

[root@centos ~]# cd /usr/local/src
[root@centos src]# wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
[root@centos src]# tar xzvf xcache-1.3.0.tar.gz
[root@centos src]# cd xcache-1.3.0
[root@centos xcache-1.3.0]# phpize
[root@centos xcache-1.3.0]# ./configure --enable-xcache
[root@centos xcache-1.3.0]# make/usr/include/php/ext/date/lib/timelib_structs.h:24:28: error: timelib_config.h: No such file or directory/usr/local/src/xcache-1.3.0/xcache.c:2959: warning: initialization discards qualifiers from pointer target type
make: *** [xcache.lo] エラー 1

失敗!
googleで検索
Posted by moo XCache
on 15.08.2009 02:52
not a XCache problem. looks like it have problem searching .h file witin the same directory which compiler are u using? i assume it's gcc... hrm... open /usr/include/php/ext/date/lib/timelib_structs.h change #include timelib_config.hto #include "timelib_config.h" (or vice versa) or #include "/usr/include/php/ext/date/lib/timelib_config.h"
とあるので、timelib_structs.h を編集、保存
再度
[root@centos xcache-1.3.0]# make
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).
[root@centos xcache-1.3.0]# make install
Installing shared extensions:     /usr/lib/php/modules/
成功!
次に設定ファイルの配置xcache.iniの内容を上記インストールディレクトリーに書き換え、パスワードを設定し保存、コピー
まず最初にコマンドラインからxcache.admin.passの値を求めてメモしておく。(******は各自適当に)
[root@centos xcache-1.3.0]# echo -n '******' | md5sum ←これをUser欄に挿入
XXXXXXXXXX ←これをパスワード欄に挿入
[xcache-common]
;; install as zend extension (recommended), normally "$extension_dir/xcache.so"
;zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
zend_extension = /usr/lib/php/modules/xcache.so
; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so
;; For windows users, replace xcache.so with php_xcache.dll
;zend_extension_ts = c:/php/extensions/php_xcache.dll
;; or install as extension, make sure your extension_dir setting is correct
; extension = xcache.so
;; or win32:
; extension = php_xcache.dll

[xcache.admin]
xcache.admin.enable_auth = On
xcache.admin.user = "*******"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = "XXXXXXXXXXX"
[root@centos xcache-1.3.0]# cp xcache.ini /etc/php.d/
Webサーバーの再起動とXcacheの起動確認
[root@centos xcache-1.3.0]# /etc/rc.d/init.d/httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
[root@centos xcache-1.3.0]# php -v
PHP 5.1.6 (cli) (built: Jan 13 2010 17:13:05)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.3.0, Copyright (c) 2005-2009, by mOo
はいOK!
続いて、ブラウザ管理の設定
adminディレクトリー内のファイルを/var/www/xcacheへコピー
[root@centos xcache-1.3.0]# mkdir /var/www/xcache
[root@centos xcache-1.3.0]# cd admin
[root@centos xcache-1.3.0]# cp * /var/www/xcache/
/var/www/xcache/をブラウザから見れるように設定する。適当にxcache.confファイルを作成し放り込む
で!設定ファイルが見れるようになりましたとさ・・・
後は後日!

2010年1月20日水曜日

1.Apacheのキャッシュ機能を有効にした場合

設定は、ここを参照

1回目

[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx-net.jp (be patient).....done

Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   21.236325 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    4.71 [#/sec] (mean)
Time per request:       2123.632 [ms] (mean)
Time per request:       212.363 [ms] (mean, across all concurrent requests)
Transfer rate:          1.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       53  502 1466.4     66    8965
Processing:   294 1590 1904.3   1167   11519
Waiting:      290 1589 1903.3   1167   11518
Total:        398 2093 2385.1   1302   11602

Percentage of the requests served within a certain time (ms)
  50%   1302
  66%   1399
  75%   1762
  80%   2037
  90%   4711
  95%   9868
  98%  10700
  99%  11602
 100%  11602 (longest request)
2回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx-net.jp (be patient).....done

Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   24.28028 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    4.16 [#/sec] (mean)
Time per request:       2402.803 [ms] (mean)
Time per request:       240.280 [ms] (mean, across all concurrent requests)
Transfer rate:          1.46 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       52  539 1089.9     68    3076
Processing:   285 1720 3026.7    919   15435
Waiting:      285 1718 3026.6    919   15434
Total:        342 2259 3539.5   1159   18424

Percentage of the requests served within a certain time (ms)
  50%   1159
  66%   1520
  75%   1882
  80%   3379
  90%   4179
  95%  14152
  98%  18274
  99%  18424
 100%  18424 (longest request)
3回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx-net.jp (be patient).....done

Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   21.620780 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    4.63 [#/sec] (mean)
Time per request:       2162.078 [ms] (mean)
Time per request:       216.208 [ms] (mean, across all concurrent requests)
Transfer rate:          1.62 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       51  776 1939.9     64    9003
Processing:   287 1269 1013.0   1029    5055
Waiting:      284 1268 1013.1   1029    5055
Total:        341 2046 2229.2   1241   10864

Percentage of the requests served within a certain time (ms)
  50%   1241
  66%   1650
  75%   3247
  80%   3409
  90%   4477
  95%   5722
  98%  10700
  99%  10864
 100%  10864 (longest request)

若干速くなったかな?のレベル!

abコマンドによるApacheサーバーの測定

Apacheサーバーの読み込み速度の向上を目指す。

まずは測定から
1回目

[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxx-net.jp (be patient).....done


Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        37584 bytes

Concurrency Level:      10
Time taken for tests:   28.921658 seconds
Complete requests:      100

Failed requests: 79   (Connect: 0, Length: 79, Exceptions: 0)
Write errors:           0
Total transferred:      826546 bytes
HTML transferred:       789264 bytes
Requests per second:    3.46 [#/sec] (mean)
Time per request:       2892.166 [ms] (mean)
Time per request:       289.217 [ms] (mean, across all concurrent requests)
Transfer rate:          27.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       51  887 2012.3     64    7519
Processing:   290 1933 2688.8   1083   15819
Waiting:      289 1864 2673.5   1063   15819
Total:        393 2821 3243.5   1224   15896

Percentage of the requests served within a certain time (ms)
  50%   1224
  66%   2863
  75%   3277
  80%   3749
  90%   7847
  95%  10987
  98%  15701
  99%  15896
 100%  15896 (longest request)
「Failed requests: 79」なんでだろう?

2回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking tachibana-net.jp (be patient).....done


Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   22.197865 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    4.50 [#/sec] (mean)
Time per request:       2219.786 [ms] (mean)
Time per request:       221.979 [ms] (mean, across all concurrent requests)
Transfer rate:          1.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       52  513 1073.0     64    3177
Processing:   285 1652 2012.3    989   13347
Waiting:      285 1651 2012.3    989   13346
Total:        339 2165 2563.8   1283   16357

Percentage of the requests served within a certain time (ms)
  50%   1283
  66%   1750
  75%   2931
  80%   3542
  90%   4922
  95%   7382
  98%  11485
  99%  16357
 100%  16357 (longest request)

3回目
[root@localhost ~]# ab -n 100 -c 10 http://xxxx-net.jp/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking tachibana-net.jp (be patient).....done


Server Software:        Apache
Server Hostname:        xxxx-net.jp
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   29.39944 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      36400 bytes
HTML transferred:       0 bytes
Requests per second:    3.44 [#/sec] (mean)
Time per request:       2903.994 [ms] (mean)
Time per request:       290.399 [ms] (mean, across all concurrent requests)
Transfer rate:          1.21 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       52  954 2424.7     65    9165
Processing:   288 1633 2457.4    965   13319
Waiting:      288 1632 2457.3    963   13318
Total:        341 2587 3746.6   1221   21347

Percentage of the requests served within a certain time (ms)
  50%   1221
  66%   1653
  75%   2385
  80%   2710
  90%   8585
  95%  10120
  98%  20832
  99%  21347
 100%  21347 (longest request)


次回から
1.Apacheのキャッシュ機能を有効にした場合
2.PHPのアクセラレーターを使った場合
3.Xoopsモジュールのキャッシュを使用した場合

を調べてみることにします。どうなることやら・・・

RPMforgeインストール&使い方

Perlモジュールパッケージ管理システム導入(cpan2rpm)において、RPMforgeのインストールが必要となったので、その方法を記述。

RPMforgeとは?
サードパーティのRPMパッケージ郡の事で、正規RPMではサポートされていない部分までサポートしてくれるリポジトリです。

1.RPMforgeインストール

# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

2.プラグインインストール
# yum -y install yum-priorities

3.設定変更
# vi /etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
※追加

以上

2010年1月18日月曜日

Apache Server カスタマイズ??

Apacheのカスタマイズについて記事を拾ってみた。
そのうち時間ができたら検証してみることに・・・

まずは参照サイトを記述

GIGAZINE

ここを参照に随時トライしてみようと思う・・・

1.BufferedLogs ディレクティブの変更
参考
apacheのコンフィグファイルにBufferedLogsディレクティブをonにする

BufferedLogs on
後は、ab(apache bench)で検証しよう。

2.mod_mem_cacheの有効化
参考1  参考2
テストした環境はDSO環境なのでApacheへのモジュール有効化はLoadModuleで行うこと。
気をつける点はmod_mem_cacheは mod_cacheのサポートモジュールとして動作するので、
モジュールを有効にする場合はmod_cacheとセットで扱うこと。
<ifmodule mod_mem_cache.c="">
CacheEnable mem /
MCacheSize 262144
MCacheMaxObjectCount 100000
MCacheMinObjectSize 1
MCacheMaxObjectSize 131072
</IfModule>

2010年1月13日水曜日

ulogd「IPTables log analyzer」のインストール

CentOSで自宅サーバー構築を参考にサイトを構築しているが、

40.2.iptablesログ解析(IPTables log analyzer)

■ulogdインストール
 ここで問題発生

[root@centos /] # ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/local/lib --with-mysql
[root@centos /] # make
ulogd_MYSQL.c:174: 警告: format '%lld' expects type 'long long int', but argument 3 has type 'int64_t' ulogd_MYSQL.c:206: 警告: format '%llu' expects type 'long long unsigned int', but argument 3 has type 'u_int64_t'
ld -shared -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto -o ulogd_MYSQL.so ulogd_MYSQL_sh.o -lc
ld: bad -rpath option
make[1]: *** [ulogd_MYSQL.so] エラー 1
make[1]: ディレクトリ `/root/work/ulogd/ulogd-1.24/mysql' から出ます
make: *** [recurse] エラー 1

Makeがうまくいかないみたい!いろいろなサイトを見てみると、どうも -rdynamic がいけないみたい。 で
Rules.make を編集(-rdynamic オプションを削除)
# mysql output support
#ULOGD_SL+=MYSQL
MYSQL_CFLAGS=-I-I/usr/include/mysql -DOLD_MYSQL=1
#MYSQL_LDFLAGS= -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto
MYSQL_LDFLAGS= -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto
再度
[root@centos /] # make
[root@centos /] # make install

今度は成功!良し良し

2010年1月4日月曜日

VMware WorkstationのBIOSを変更してOEM版Windowsの認証を回避できるみたい!

これは面白い!メモ、メモ

まずは変更するBIOSファイルを入手します。腕のある方なら自分で作ってもOK。

・Bios Build v.295 for VMWare v6.5.3 (Dell Slic 2.1 + Multi SLP 1.0)
http://rapidshare.com/files/297106763/VM.DELL.SLIC.21.SLP.IMAGE.rar
・Bios Build v.314 for VMWare v7.0.0 (Dell Slic 2.1 + Multi SLP 1.0)
http://rapidshare.com/files/310472637/VM.314.DELL.SLIC.21.MULTI-SLP.10.IMAGE.ROM
・Bios Build v.314 for VMWare v7.0.0 (Dell Slic 2.1 + Multi SLP 1.0 + XP Mode Activation)
http://rapidshare.com/files/310879279/VM.314.DELL.SLIC.21.MULTI-SLP.10.XP-MODE.IMAGE.ROM
どれかファイルを入手したら、早速実験。
まずは普通通りにVMwareで仮想マシンを作成。

そして作成された仮想マシンの.vmxファイルに、以下ようにBIOSファイル名の文字を追記。
bios440.filename = "VM.DELL.SLIC.21.SLP.IMAGE.ROM"
そのあと、.vmxファイルと同じ場所にBIOSファイルを置いてあげれば準備完了。
この状態で仮想マシンを起動させ、次のような感じでBIOS画面が変更されていれば成功。


DELL SLIC v2.1と表示されます。
あとは普通にOEMのディスクでWindowsをインストールすれば、アクティベーション無しです。

VMware Workstation7 で USB2 の有効化

vmx ファイルに以下の行を追加

usb.present = "TRUE" # USB を利用
ehci.present = "TRUE" # EHCI コントローラを有効化
これで有効化できました。

リダイレクトの仕方

サーバーのログを見ていると、以前のトップファイル(あえてtop.phpとしていた)にアクセスする人がかなり多い。
もしかしたら、ページが表示されなくて未だに閉鎖中と思う方も多いと思ったので、リダイレクトしホームページを見ていただくようにした。

ネットで調べてみると幾つかの方法があるようです。
おもなリダイレクトの方法のなかから三つを試してみた。

  1. 301リダイレクトと呼ばれる方法で、.httaccessを使うなどして行うもの。
  2. HTML<meta http-equiv="Refresh" ...>を使う方法
  3. JavaScriptのlocation.href、またはlocation.replace()を使う方法
1.301リダイレクト
サーバー側に.htaccessを設置する方法。具体的なコードは以下。
Redirect permanent /top.php http://hogehoge.jp/index.php
Redirect permanent /top.html http://hogehoge.jp/index.php

top.phpにアクセスした場合に、index.phpにリダイレクトする
top.htmlにアクセスした場合に、index.phpにリダイレクトする

2.HTMLファイルのヘッダーに直接書き込む方法
head要素内に下記のようなコードを書けば良いだけです。簡単。しかし・・・
<meta http-equiv="Refresh" content="0; URL=/index.php">
/index.php に0秒後にリダイレクトする
*古いURLにリダイレクト用のHTMLを残しておかねばならない。

3.JavaScriptを使ってリダイレクトする
しかしlocation.hrefを使うと"「戻る」ボタンで戻れない問題"が発生するので、履歴の残らないlocation.replace()の方がいいかも(こちらでは戻れる)。
この手法も古いURLにリダイレクト用のHTMLファイルを置いておかねばならないという点で、1.に劣る。

したがって、今回は1.301リダイレクトの手法を選択した。