coLinux日記

coLinuxはフリーソフトを種として、よろずのシステムとぞなれりける。

ファイルシステムサイズ増設2

2007-01-31 22:34:01 | インストールと設定
前回に続いて、サイズを大きくした新しいファイルシステム fs-home5G に /home の内容をコピーします。
まず、新しいファイルシステムを確認します。
# mount /dev/cobd3 /mnt
# df /home /mnt
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cobd2             2064208   1911028     48324  98% /home
/dev/cobd3             5160576    141440   4756992   3% /mnt
# ls /mnt
lost+found
#

/home の内容をコピーします。ここでは、dump と restore を使います。
# cd /mnt
# dump -0u -f - /home |restore -rf -
  DUMP: Date of this level 0 dump: Wed Jan xx 22:18:38 2007
  DUMP: Dumping /dev/cobd2 (/home) to standard output
  DUMP: Label: none
  DUMP: Writing 10 Kilobyte records
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 1947516 blocks.
  DUMP: Volume 1 started with block 1 at: Wed Jan xx 22:18:39 2007
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
restore: ./lost+found: File exists
  DUMP: 80.85% done at 5248 kB/s, finished in 0:01
  DUMP: Volume 1 completed at: Wed Jan xx 22:24:41 2007
  DUMP: Volume 1 1945290 blocks (1899.70MB)
  DUMP: Volume 1 took 0:06:02
  DUMP: Volume 1 transfer rate: 5373 kB/s
  DUMP: 1945290 blocks (1899.70MB)
  DUMP: finished in 362 seconds, throughput 5373 kBytes/sec
  DUMP: Date of this level 0 dump: Wed Jan xx 22:18:38 2007
  DUMP: Date this dump completed:  Wed Jan xx 22:24:41 2007
  DUMP: Average transfer rate: 5373 kB/s
  DUMP: DUMP IS DONE
#

# ls /home
data  espiya  intel  local  lost+found  mysql  named  sser01  www
# ls /mnt
data    intel  lost+found  named            sser01
espiya  local  mysql       restoresymtable  www
# df /home /mnt
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cobd2             2064208   1911028     48324  98% /home
/dev/cobd3             5160576   2051600   2846832  42% /mnt
#

およそ 6 分かかりました。うまくコピーできました。fsck もしてみます。
# cd /
# sync;sync
# umount /mnt
# fsck /dev/cobd3
fsck 1.38 (30-Jun-2005)
e2fsck 1.38 (30-Jun-2005)
/dev/cobd3: clean, 54369/655360 files, 533476/1310720 blocks
#

シャットダウンして、fedora5.bat を以下のように修正して完了です。
colinux-daemon.exe kernel=vmlinux initrd=initrd.gz mem=128 
   cobd0=Fedora5-2gb.ext3 cobd1=swap.img  cobd2=fs-home5G 
   cofs0=C:\Temp 
   eth0=pcap-bridge,"ローカル エリア接続" 
   root=/dev/cobd0 fastboot nogui
(1 行です。)

fedora5.bat をダブルクリックして df コマンドを実行してみます。
$ df /home
Filesystem           1K-ブロック    使用   使用可 使用% マウント位置
/dev/cobd2             5160576   2051632   2846800  42% /home
$

これで当分大丈夫です。dump と restore で、サイズが異なっても、ext2 から
ext3 へのコピーもできることが分かりました。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

ファイルシステムサイズ増設

2007-01-29 22:59:31 | インストールと設定
coLinux を2ヶ月程使っていたら、ついに /dev/cobd2 がいっぱいになってしまいました。早いですね。この調子だと、最初の Root FS image だけで、どんどん yum でインストールしていたら、あっというまにあふれてしまうところでした。
$ df /dev/cobd2
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cobd2             2064208   1911052     48300  98% /home
$

2006-12-22の記述に従って、FS image を拡張してみます。今回は、
$ echo '5*1024*1024*1024' |bc
5368709120
$

で、5GB にしてみます。2006-12-06の fsutil コマンドを使います。Windows側で、「コマンドプロンプト」窓を開いて実行します。
C:\> cd coLinux
C:\coLinux> fsutil file createnew fs-home5G 5368709120

これで、5GB のファイル fs-home5G が作成されました。早速、coLinux に認識させます。coLinux をシャットダウンして、C:coLinuxfedora5.bat を修正して、以下のようにします。
colinux-daemon.exe kernel=vmlinux initrd=initrd.gz mem=128 
  cobd0=Fedora5-2gb.ext3 cobd1=swap.img  cobd2=fs-home 
  cobd3=fs-home5G cofs0=C:Temp eth0=pcap-bridge,"ローカル エリア接続" 
  root=/dev/cobd0 fastboot nogui
(1 行です。)

coLinux をブートしてファイルシステムの移行作業を行います。
# mkfs -t ext3 /dev/cobd3

とここで、TeraTerm が突然終了して、あわててコンソールを見たところ、動きが異常におそくなっています。ps コマンドで確認したところ、まだ mkfs は動いているようです。しばらく様子を見ていると何とか終了しました。sshd と bash も動いたままでしたのでなぞです。
関連するプロセスを kill して、もう一度 mkfs しなおしたらすぐ完了しました。中身がめちゃくちゃだと時間がかかるようです。
# mkfs -t ext3 /dev/dobd3 
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
#

ext3 にすると空き領域が少し減るので、ext2 でもいいと思います。続きは次回に。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Free Pascal Compiler

2007-01-26 00:17:44 | コンピュータ言語
前回、Fortran をインストールしたので、もうひとつのコンパイラである、Pascal をインストールします。GNUプロジェクトから、Free software directory をたどって探すと、Free Pascal Compiler ( http://www.freepascal.org/ ) にたどり着きました。コマンド名は fpc ( Version 2.0.4 )です。通常のようにコンパイルしたいところですが、おそらく Pascal は、Pascal 自身で書かれている可能性が高いので何もない状態でのコンパイルによるインストールは敷居が高いと予想されます。そこであっさりあきらめて、この間作った prog.list の中を探すと、fpc.i386 , fpc-doc.i386 , fpc-src.i386 があります。そのうち、fpc.i386 と fpc-doc.i386 をインストールしました。
# yum install fpc.i386
...............
# yum install fpc-doc.i386
...............
# which fpc
/usr/bin/fpc
# fpc -iV -iTO -iTP
2.0.4 linux i386
#

ためしに、Free Pascal 自身をコンパイルしてみます。
$ tar xzf fpcbuild-2.0.4.tar.gz
$ cd fpcbuild_2.0.4_exp
$ cp install/makepack .
$ chmod +x makepack
$ ./makepack
FPC Source: i386-linux
FPC Target: i386-linux
Libgdb (fpcsrc/libgdb/linux/i386/libgdb.a) not found, aborting
$

libgdb.a がないのでコンパイルできません。そこで、makepack の中の
CHECKLIBGDB=no

とします。documentation archive に関するエラーがでるので、makepack の中のそのあたりをすべてコメントにします。
$ ./makepack
.....................
/usr/bin/ppc386 -XX -CX -Ur -Xs -OG2p3 -n -Fui386 -Fusystems
 -Fu/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc/rtl/units/i386-linux 
 -Fii386 -FE. -FUi386/units/i386-linux -dRELEASE  -di386 -dGDB 
 -dBROWSERLOG -Fux86 pp.pas
pp.pas(209,1) Error: Can't call the linker, switching to external linking
make[6]: *** [ppc386] エラー 1
make[6]: Leaving directory `/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc/compiler'
make[5]: *** [next] エラー 2
make[5]: Leaving directory `/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc/compiler'
make[4]: *** [ppc1] エラー 2
make[4]: Leaving directory `/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc/compiler'
make[3]: *** [cycle] エラー 2
make[3]: Leaving directory `/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc/compiler'
make[2]: *** [compiler_cycle] エラー 2
make[2]: Leaving directory `/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc'
make[1]: *** [build-stamp.i386-linux] エラー 2
make[1]: Leaving directory `/home/espiya/src/fpcbuild_2.0.4_exp/fpcsrc'
make: *** [fpcsrc/build-stamp.i386-linux] エラー 2
$

残念、途中まではコンパイルできたのですがだめでした。とりあえずあきらめて、何かサンプルを動かして終わりにします。「自作コンパイラの部屋のサンプルプログラム」( http://www.tokumaru.org/plang/cabezon/samples.htm ) の「8クイーン」プログラムを queen.pas ファイルにしてテストします。
$ fpc queen.pas
Free Pascal Compiler version 2.0.4 [2006/09/20] for i386
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Linux for i386
Compiling queen.pas
Linking queen
60 Lines compiled, 0.1 sec
$ ls
queen  queen.o  queen.pas
$ ./queen
1 : 1 5 8 6 3 7 2 4
......................
92 : 8 4 1 3 6 2 7 5
解の個数= 92
$

うまくいきました。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Intel Fortran Compiler テスト

2007-01-19 22:49:18 | コンピュータ言語
前回非商用Linux版 Intel Fortran Compiler 9.1 で -fast オプションを指定したら動きませんでした。ifort --help を実行して見ます。
$ ifort --help 
...................
-fast  enable -xP -O3 -ipo -no-prec-div -static
...................
-ax<codes> generate code specialized for processors specified by <codes>
           while also generating generic IA-32 code.  <codes> includes
           one or more of the following characters:
    K  Intel Pentium III and compatible Intel processors
    W  Intel Pentium 4 and compatible Intel processors
    N  Intel Pentium 4 and compatible Intel processors.  Enables new
       optimizations in addition to Intel processor-specific optimizations
    P  Intel Core(TM) Duo processors, Intel Core(TM) Solo processors, Intel
       Pentium 4 and compatible Intel processors with Streaming SIMD
       Extensions 3 (SSE3) instruction support
    B  Intel Pentium M and compatible Intel processors
-x<codes>  generate specialized code to run exclusively on processors
           indicated by <codes> as described above.
....................
$

-xP オプションのせいみたいです。そこで、姫野ベンチ を改めて、-O3 でコンパイルします。
$ ifort -O3 himenoBMTxp.f90
............
$ ./a.out
 Select Grid-size:
 Grid-size=
            XS (64x32x32)
            S  (128x64x64)
            M  (256x128x128)
            L  (512x256x256)
            XL (1024x512x512)
XS
  mimax=          65  mjmax=          33  mkmax=          33
  imax=          64  jmax=          32  kmax=          32
  Time measurement accuracy : .10000E-03
  Start rehearsal measurement process.
  Measure the performance in 3 times.
   MFLOPS:   431.1818       time(s):  1.320000000000000E-002  6.2296884E-03
 Now, start the actual measurement process.
 The loop will be excuted in       13636  times.
 This will take about one minute.
 Wait for a while.
  Loop executed for        13636  times
  Gosa :  1.0093708E-11
  MFLOPS:   425.1774       time(s):   60.8457000000000
  Score based on Pentium III 600MHz :   5.132514
FORTRAN PAUSE
PAUSE prompt>
$

動きました。S も実行します。
$ ./a.out
 Select Grid-size:
 Grid-size=
            XS (64x32x32)
            S  (128x64x64)
            M  (256x128x128)
            L  (512x256x256)
            XL (1024x512x512)
S
  mimax=         129  mjmax=          65  mkmax=          65
  imax=         128  jmax=          64  kmax=          64
  Time measurement accuracy : .10000E-03
  Start rehearsal measurement process.
  Measure the performance in 3 times.
   MFLOPS:   431.0915       time(s):  0.114600000000000  3.2962142E-03
 Now, start the actual measurement process.
 The loop will be excuted in        1570  times.
 This will take about one minute.
 Wait for a while.
  Loop executed for         1570  times
  Gosa :  1.8456948E-04
  MFLOPS:   452.6762       time(s):   57.1143000000000
  Score based on Pentium III 600MHz :   5.464464
FORTRAN PAUSE
PAUSE prompt>
$

これはすごい。coLinux は、Fortran 開発環境としても十分に機能します。
私のような古い PC を使っている場合は、-fast を使わずに -x オプションを指定すればいいはずです。実際に、
$ ifort -xN -O3 -ipo -no-prec-div -static himenoBMTxp.f90 

のように指定すれば正しく動作しました。利用の際はオプションを確認しましょう。

coLinux 上の Intel Fortran Compiler でコンパイルしたプログラムは、Windows XP が安定して動いている限り、何日でも実行できます。Intel Fortran Compiler を購入する計画のあるところで、まだ Linux マシンを用意できない場合に、先行してプログラム開発を行いたいようなときは、coLinux がお勧めです。ただし、メモリはふんだんに用意しておく必要があります。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Intel Fortran Compiler

2007-01-18 22:46:45 | コンピュータ言語
今回は、Fortran に挑戦してみます。

早速、Intel Fortran compiler (http://www.intel.com/) を試してみます。というのも、商用コンパイラでありながら、非商用の Linux 用コンパイラを提供してくれる大変ありがたいものだからです。Intel Chip ベースの共有のスーパーコンピュータを使っている場合など、coLinux でこのコンパイラが使えれば非常に役立つと思います。

非商用版の Linux 用コンパイラ Intel Fortran Compiler for Linux
l_fc_c_9.1.036_ia32.tar.gz

をインストールします。ダウンロード時に表示されたシリアルナンバーを用意します。普通にインストールすると、/opt/intel にインストールされてしまうので、あらかじめ /home の方にリンクしておきます。install.sh を実行して、質問にどんどん答えていけば簡単にインストールできるはずです。
$ cd ~/src
$ tar xvzf l_fc_c_9.1.036_ia32.tar.gz
$

# mkdir /home/intel
# cd /opt
# ln -s /home/intel intel
# cd ~espiya/src/l_fc_c_9.1.036
# ./install.sh
................
#

$ source /opt/intel/fc/9.1.036/bin/ifortvars.sh
$ ifort -help
                     Intel(R) Fortran Compiler Help
                     ==============================
.............................
Copyright (C) 1985-2006, Intel Corporation.  All rights reserved.

* Other brands and names are the property of their respective owners.
$

無事に fortran がインストールできました。
試しに、姫野ベンチ( http://accc.riken.jp/HPC/HimenoBMT/index.html)を実行してみます。
f90_xp.lzh

を実行することにします。
$ cd bench/f90_xp
$ ifort -fast himeno_BMTxp.f90
IPO: performing single-file optimizations
IPO: generating object file /tmp/ipo_ifort1KKy9n.o
himenoBMTxp.f90(315) : (col. 5) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(235) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(236) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(237) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(238) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(239) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(240) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(241) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(243) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(244) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(245) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(246) : (col. 2) remark: LOOP WAS VECTORIZED.
himenoBMTxp.f90(248) : (col. 5) remark: LOOP WAS VECTORIZED.
$ ls
a.out  bound.mod  himenoBMTxp.f90  mtrx.mod  others.mod  pres.mod  work.mod
$

うまくコンパイルできました。早速実行してみます。
$ ./a.out

Fatal Error : This program was not built to run on the processor in your 
                system.
$

うまく動きません。-fast オプションは使えないようです。

続きは次回に書きます。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

apache httpd 2.2.4 インストール

2007-01-15 21:16:54 | Apache httpd
Apache httpd 2.2.4 がでました。早速、2.2.3 と入れ替えてみましょう。
$ md5sum httpd-2.2.4.tar.gz
3add41e0b924d4bb53c2dee55a38c09e  httpd-2.2.4.tar.gz
$ cat httpd-2.2.4.tar.gz.md5
3add41e0b924d4bb53c2dee55a38c09e  httpd-2.2.4.tar.gz
$ gpg --verify httpd-2.2.4.tar.gz.asc
gpg: 2007年01月06日 15時49分21秒 JSTにRSA鍵ID 10FDE075で施された署名
gpg: “wrowe@covalent.net”からの正しい署名
gpg:                 別名“wrowe@lnd.com”
gpg:                 別名“wrowe@apache.org”
gpg:                 別名“William A. Rowe, Jr. <wrowe@rowe-clan.net>”
gpg: 警告: この鍵は信用できる署名で証明されていません!
gpg:       この署名が所有者のものかどうかの検証手段がありません。
主鍵の指紋: 33 16 9B 46 FC 12 D4 01  CA 6D DB D7 DE EA 4F D7
$ 

コンパイルするときに、ついでに前回設定していなかった、WebDAV 関連も指定しておきます。
$ tar xzf httpd-2.2.4.tar.gz
$ cd httpd-2.2.4
$ ./configure --prefix=/usr/local/httpd224 --enable-usertrack --enable-auth-digest \
             --enable-ssl --enable-rewrite --enable-so \
             --enable-dav --enable-dav-fs --enable-dav-lock
...................
config.status: executing default commands
$ make
...................
$

# make install
...................
#

設定ファイルは、2.2.3 , 2.2.4 の original を diff で比較したところ、httpd223 を httpd224 に変更しただけです。そこで、2.2.3 の設定ファイルで修正したものを、コピーして修正します。
# cd /usr/local/httpd224/conf
# cp /usr/local/httpd223/conf/httpd.conf httpd.conf
# cp /usr/local/httpd223/conf/extra/httpd-{languages,mpm,ruby}.conf extra
# vi httpd.conf
(以下のコマンドで一括変換します。)
:1,$s/httpd223/httpd224/

# 

php と ruby-mod は、再インストールするべきですが、とりあえず httpd223/modlues/{libphp5.so,mod_ruby.so} をコピーします。
# cd /usr/local/httpd224/modules
# cp /usr/local/httpd223/modules/{libphp5.so,mod_ruby.so} .
#

更に、/etc/init.d/httpd を 2.2.4 のものに変更します。
# cd /etc/init.d
# cp /usr/local/httpd224/bin/apachectl httpd
# vi httpd
(次のコメント行を追加します。)
  # Comments to support chkconfig on RedHat Linux
  # chkconfig: 3 65 35
  # description: Apache httpd Web server

#

DocumentRoot と ScriptAlias /cgi-bin/ は変更していないので、何もする必要はありません。これで、入れ替えの準備ができました。
# cd /etc/init.d
# /usr/local/httpd223/bin/apachectl stop
# ./httpd start

確認してみます。
# lynx -dump -head http://www.example.co.jp/
HTTP/1.1 200 OK
Date: Sat, xx Jan 2007 xx:xx:xx GMT
Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.8a DAV/2 PHP/5.2.0 mod_ru
by/1.2.6 Ruby/1.8.5(200x-xx-xx)
Last-Modified: Thu, xx Jan 2007 14:40:39 GMT
ETag: "3c02a-88-c34ea7c0"
Accept-Ranges: bytes
Content-Length: 136
Connection: close
Content-Type: text/html
Content-Language: ja

#

うまく動いたので /usr/local/httpd のリンク先も変えておきます。
# cd /usr/local
# rm httpd
# ln -s httpd224 httpd
#

Apache httpd 2.2.4 も動きだしました。500 のメッセージの問題は変更ないみたいです。

ソースからコンパイルした場合、バージョンアップをどのような手順でするかは、一度考えておく必要があるのですが、coLinux なら簡単にテストできるから便利です。古いバージョンは安定したら消去します。その際、ログが必要なら、

/usr/local/httpd223/logs/{access_log,error_log}

だけを保存しておけばよいです。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Apache httpd あれこれ

2007-01-13 22:37:29 | Apache httpd
前回うまく動作した、hello.rbx をわざと hello.rb(もちろんシェルで実行しても動かないです。)にコピーして参照すると、エラーになるはずです。試してみます。
$ lynx -dump http://www.example.co.jp/cgi-bin/hello.rb
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>>00 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
....................
</body></html>

$

です。一応うまくエラーになっていますが、html が正しく認識されていません。httpd の設定がどこか間違っているからでしょうか。lynx でチェックしてみます。
$ lynx -dump -head http://www.example.co.jp/cgi-bin/hello.rb
HTTP/1.1 500 Internal Server Error
Date: Tue, xx Jan 2007 12:40:11 GMT
Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.8a PHP/5.2.0 mod_ruby/1.2
.6 Ruby/1.8.5(200x-xx-xx)
Connection: close
Content-Type: text/plain
Content-Language: ja

$

Content-Type: text/plain になっています。存在しないファイルのアクセスのエラーのときは、
$ lynx -dump -head http://www.example.co.jp/cgi-bin/hello
HTTP/1.1 404 Not Found
Date: Tue, xx Jan 2007 12:44:55 GMT
Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.8a PHP/5.2.0 mod_ruby/1.2
.6 Ruby/1.8.5(200x-xx-xx)
Connection: close
Content-Type: text/html; charset=iso-8859-1

$

のようになっていますので、500 の時におかしくなっています。conf ファイルでこれを制御する部分? はデフォルトですので、この出力結果はモジュールで内部生成されているようです。ソース内の modules ディレクトリ内を調べたところ、modules/http/http_protocol.c 内の get_canned_error_string で</h1> 以下を生成しているようです。これは、ap_send_error_response で呼び出していますが、このときに、ap_set_content_type が呼び出されていないのがこうなる理由みたいです。500 は、httpd.conf で ErrorDocument を指定して回避するとして、別の HTML ファイルで置き換えても、Content-type は変更できないみたいなので、
ErrorDocument 500 "500 Internal Server Error"

のような指定でしょうか。

もう1つ気がついたのは、設定では、localhost からのアクセスをロックしてあるのですが、
# lynx -dump http://localhost/cgi-bin/hello.rbx
                                   Forbidden

   You don't have permission to access /cgi-bin/hello.rbx on this server.

# tail -1 /usr/local/httpd/logs/error_log
[Mon Jan xx xx:xx:xx 2007] [error] [client 127.0.0.1] client denied by
                       server configuration: /home/data/cgi-bin/hello.rbx
# lynx -dump http://www.example.co.jp/cgi-bin/hello.rbx
Hello, World.

# tail -1 /usr/local/httpd/logs/access_log
192.168.1.100 - - [xx/Jan/2007:xx:xx:xx +0900] "GET /cgi-bin/hello.rbx HTTP/1.0" 200 13
#

つまり、lynx は、http://localhost で参照すると、127.0.0.1 としてhttpd に接続し、http://www.example.co.jp で参照すると、192.168.1.100 として接続するのですね。いつも、127.0.0.1 で接続しているのかと思ってました。ということは、2006-12-26の記述は誤りで訂正しておきます。別のケースを勘違いしたみたいです。

今回は、どうでもいいことを書き、また間違いも見つけてしまいましたが、coLinux の場合、完全な実験環境としてどんどんいじれるので気楽でいいです。Apache httpd も 2.2.4 がリリースされたのでそちらも試してみたいです。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

ruby mod_rubyとeruby

2007-01-10 22:44:34 | コンピュータ言語
ruby もインストールできましたので、Webで使いやすいように mod_ruby (http://www.modruby.net/ja/)関連もインストールします。
mod_ruby-1.2.6.tar.gz
eruby-1.0.5.tar.gz

をダウンロードします。展開してインストールを試みましょう。
$ tar xvzf mod_ruby-1.2.6.tar.gz
$ cd mod_ruby-1.2.6
$ ./configure.rb --with-apxs=/usr/local/httpd/bin/apxs
................
$ make
................
$

# make install
................
#
# cp examples/httpd.conf /usr/local/httpd/conf/extra/httpd-ruby.conf
#

続いて、eruby です。
$ tar xvzf eruby-1.0.5.tar.gz
$ cd eruby-1.0.5
$ ./configure --with-charset=utf-8
................
$ make
................
# make install
................
#

設定してみます。先ほどインストールした、httpd-ruby.conf を修正します。
# vi /usr/local/httpd/conf/extra/httpd-ruby.conf
(次の行を修正します。)

LoadModule ruby_module /usr/local/httpd/modules/mod_ruby.so
<IfModule mod_ruby.c>
  RubyRequire apache/ruby-run
  <Location /ruby>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    Options +ExecCGI
  </Location>
  <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
  RubyRequire apache/eruby-run
  <Location /eruby>
    SetHandler ruby-object
    RubyHandler Apache::ERubyRun.instance
  </Location>
  <Files *.rhtml>
    SetHandler ruby-object
    RubyHandler Apache::ERubyRun.instance
  </Files>
  RubyRequire apache/erb-run
  <Location /erb>
    SetHandler ruby-object
    RubyHandler Apache::ERbRun.instance
  </Location>
</IfModule>

# vi /usr/local/httpd/conf/httpd.conf
(次の行を追加します。)

Include conf/extra/httpd-ruby.conf

#

こういうとき、extra ディレクトリ下に設定ファイルが分散できるようになったのは便利ですね。
httpd を再起動してテストします。
# /etc/rc.d/init.d/httpd restart
.............
#

example/test.rhtml を DocumentRoot の下において、ブラウザで見ると、正しく実行されました。eruby は OK です。
次に、次のような ruby プログラムを
print("Hello, World. \n" );

hello.rbx ファイルにして、ブラウザで見ると、hello.rbx は、Forbidden になります。
/usr/local/httpd/logs/error_log に
[error] access to /home/data/www/espiya/ruby/hello.rbx failed 
        for (null), reason: Options ExecCGI is off in this directory

と記録されているように、ExecCGI が禁止されているからです。ScriptAlias で指定されている /home/data/cgi-bin に ExecCGI が指定されていることを確認して、そこに移動してみます。
 
# mv hello.rbx /home/data/cgi-bin
#

として、参照すると、
[error] access to /home/data/cgi-bin/hello.rbx failed for (null), 
        reason: file permissions deny server execution

このようなエラーがでます。実行可能にしておく必要があります。
# chmod +x /home/data/cgi-bin/hello.rbx
# cd /home/data/cgi-bin/
# ./hello.rbx 
./hello.rbx: line 1: syntax error near unexpected token `"Hello, World.\n"'
./hello.rbx: line 1: `print("Hello, World.\n");'
# ruby hello.rbx
Hello, World.
#

このように、そのファイルは実行できないが、ruby に渡せば実行できる状態でも、.rbx をつけておけばブラウザで参照すると、mod_ruby によって、ruby に渡されて実行できるようになるわけです。これでブラウザから参照すると以下のようになります。
$ lynx -dump http://www.example.co.jp/cgi-bin/hello.rbx
Hello, World.

$

うまく動いています。次回は、mod_ruby テストで分かった、httpd のことについて述べたいと思います。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

rubyインストール

2007-01-08 22:53:38 | コンピュータ言語
今まで、coLinux を使ってきましたが、ほとんど普通の Linux と変わらない環境をたった1つのマシンで、Windowsと共存させて利用できることが確認できました。

仕事関連のいわゆる LAMP 環境が一段落したので、coLinux の利用方法を考えて見ます。

最初に思いついたのは、コンピュータ言語の習得の為の環境です。

世の中には、様々なコンピュータ言語が存在しますが、Windows 環境では、この環境に特化したコンピュータ言語以外は利用しようとしてもいろいろ制約があって難しそうです。特に現在生まれてくる新しいコンピュータ言語は、そのほとんどが、UNIX の流れをくむ OS 上で動作するように配布されていることを考えると、どうしても Linux が動く環境が欲しくなります。しかし通常は Windows も必要ですから、Windows 環境は boot 関連やディスクパーティションも含めて変更したくない場合にそれらを同時に動かすには、2台のマシンを用意する必要がありました。

2台のマシンを置くスペースまたは資金がない場合に coLinux が最適な環境を与えてくれると思います。coLinux なら Windows 環境を一切変更せずに( coLinux をアンインストールすると元の Windows に戻るという意味です )、C , C++ などのコンパイラであろうと、perl , ruby といったインタプリタであろうと、データベース関係の SQL であろうと、ほとんどすべてが無料で利用できる訳ですから、この環境を利用して新しい言語にどんどん挑戦したいものです。

というわけで、今後しばらくは、コンピュータ言語をインストールしていくつもりです。最初は、ruby 1.8.5 P12 をインストールします。
http://www.ruby-lang.org/ からたどってソースをダウンロードします。
$ lynx http://www.ruby-lang.org/
....................
$ ls -l ruby*
-rw-r--r-- 1 espiya user 4526961 ............. ruby-1.8.5-p12.tar.gz
$

展開、コンパイル、インストールします。
$ tar xvzf ruby-1.8.5-p12.tar.gz
$ cd ruby-1.8.5-p12
$ ./configure
....................
$ make
....................
$ make test
test succeeded
$

# make install
....................
#

$ ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux]
$

うまくインストールできました。次回はもう少し ruby 周りで何かしたいと思います。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

php 5.2.0 インストール

2007-01-04 23:58:56 | php
新年の最初は、php をインストールします。
PHP の公式サイト(http://www.php.net/)を見ると、現在は PHP 5.2.0 です。ソースファイルは、
php-5.2.0.tar.gz
md5: 52d7e8b3d8d7573e75c97340f131f988

です。早速展開して、コンパイルしてみます。
$md5sum php-5.2.0.tar.gz
52d7e8b3d8d7573e75c97340f131f988  php-5.2.0.tar.gz
$

$ tar xvzf php-5.2.0.tar.gz
.........................
$ cd php-5.2.0
$ ./configure --prefix=/usr/local/php520  --enable-mbstring \
              --with-mysql=/usr/local/mysql \
              --with-openssl --with-apxs2=/usr/local/httpd/bin/apxs
.........................
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
$

libxml2 がありませんでした。
これを入れます。
# yum install libxml2-devel.i386
.........................
Installed: libxml2-devel.i386 0:2.6.23-1.2
Complete!
#

$ ./configure --prefix=/usr/local/php520  --enable-mbstring \
              --with-mysql=/usr/local/mysql \
              --with-openssl --with-apxs2=/usr/local/httpd/bin/apxs
.........................
Thank you for using PHP.

$ make
.........................
Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

$

# make install
.........................
#

AddType application/x-httpd-php .php .phtml
行がないみたいなので、conf/httpd.conf にとりあえず追加しておきます。

設定ファイルをコピーします。
# cp php.ini-dist /usr/local/php520/lib/php.ini

mbstring の設定を行います。
http://search.net-newbie.com/php/ref.mbstring.htmlを参考に php.ini を修正します。
# vi /usr/loca/php/lib/php.ini
(次の行を直しました。)

mbstring.language = neutral
mbstring.internal_enonding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = On

#

日本語のWebページも作るので、nkf も入れておきます。
# yum install nkf.i386
..............................
#

コマンドオプションは、-j が JIS , -s が SJIS , -e が EUC , -w が UTF-8 です。

これで設定は完了です。日本語がうまく表示されないような場合は後で修正します。
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする