Oct 23, 2002
onlsbc1: Red Hat Linux 7.3システムでのJavaの実行
--- コンパクトフラッシュ上でのhello world実行#3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(http://www-online.kek.jp/~inoue/para-CAMAC/
Work/SBC-Java2.html)
高エネルギー加速器研究機構
素粒子原子核研究所
物理、オンライングループ
井上 栄二
目的
SBCのコンパクトフラッシュ上にインストールしたLinuxシステムは、容量に
よる制約からフルシステムではない。 一部のファイルしかインストール
されていないLinuxシステム上で、Java v1.4.1 が正常に動けるかどうかを
確認するために、JavaRMI、Hello Worldを実行してみる。
(1). サンプルプログラムのコンパイル
(2). RMI レジストリ、サーバ、およびアプレットの起動
(3). サンプルプログラムの実行
--------------------------------------------------------------------
(1). サンプルプログラムのコンパイル
現在の実行環境をチェックする。
(1-1). Javaのチェック
[inoue@onlsbc1 inoue]$ df -k
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hdc1 483886 316801 142089 70% /
none 152332 0 152332 0% /dev/shm
[inoue@onlsbc1 inoue]$ which java
/usr/java/bin/java
[inoue@onlsbc1 inoue]$ ls -lL /usr/java
合計 10419
-r--r--r-- 1 root root 4431 8月 29 19:14 COPYRIGHT
-r--r--r-- 1 root root 16994 8月 29 19:14 LICENSE
-r--r--r-- 1 root root 8729 8月 29 19:14 README
-r--r--r-- 1 root root 15639 8月 29 19:14 README.html
drwxr-xr-x 2 root root 1024 8月 29 19:15 bin
drwxr-xr-x 6 root root 1024 8月 29 19:14 demo
drwxr-xr-x 3 root root 1024 8月 29 19:14 include
drwxr-xr-x 5 root root 1024 8月 29 19:13 jre
drwxr-xr-x 2 root root 1024 8月 29 19:14 lib
drwxr-xr-x 4 root root 1024 8月 29 19:15 man
-rw-r--r-- 1 root root 10568947 8月 29 19:14 src.zip
[inoue@onlsbc1 inoue]$
[inoue@onlsbc1 inoue]$ java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
[inoue@onlsbc1 inoue]$
/dev/hdc1 のコンパクトフラッシュ上にLinux システムが構築されており、
Java は /usr/java下のディレクトリに配置されている。
(1-2). 実行環境
[inoue@onlsbc1 inoue]$ env
PWD=/home/inoue
HOSTNAME=onlsbc1.kek.jp
LESSOPEN=|/usr/bin/lesspipe.sh %s
USER=inoue
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;0
1:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.b
tm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:
*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*
.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;3
5:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
MAIL=/var/spool/mail/inoue
OLDPWD=/home/inoue/Java
INPUTRC=/etc/inputrc
LANG=ja_JP.eucJP
SSH_CLIENT=130.87.153.2 3130 22
LOGNAME=inoue
SHLVL=1
SHELL=/bin/bash
HISTSIZE=1000
HOME=/home/inoue
TERM=vt100
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/inoue/bin:/usr/java/bin
JLESSCHARSET=japanese
SSH_TTY=/dev/pts/0
_=/usr/bin/env
[inoue@onlsbc1 inoue]$
(1-3). サーバ側の準備
この実行で使用するソースコードは、以下のURLから入手した。
http://java.sun.com/j2se/1.4.1/docs/guide/rmi/archives/getStart.tar
パッケージ名は examples.hello、ソースディレクトリは
~/JavaRMI/getStart/examples/hello である。
[inoue@onlsbc1 JavaRMI]$ pwd
/home/inoue/JavaRMI
[inoue@onlsbc1 JavaRMI]$ ls -l
合計 14
-rw-r--r-- 1 inoue inoue 13312 10月 21 16:38 getStart.tar
[inoue@onlsbc1 JavaRMI]$ tar xf getStart.tar
[inoue@onlsbc1 JavaRMI]$ ls -l
合計 15
drwxr-xr-x 2 inoue inoue 1024 1月 26 2002 getStart
-rw-r--r-- 1 inoue inoue 13312 10月 21 16:38 getStart.tar
[inoue@onlsbc1 JavaRMI]$ rm getStart.tar
[inoue@onlsbc1 JavaRMI]$ ls -lR
.:
合計 1
drwxr-xr-x 2 inoue inoue 1024 1月 26 2002 getStart
./getStart:
合計 10
-rw-r--r-- 1 inoue inoue 1998 1月 26 2002 Hello.java
-rw-r--r-- 1 inoue inoue 2574 1月 26 2002 HelloApplet.java
-rw-r--r-- 1 inoue inoue 2779 1月 26 2002 HelloImpl.java
-rw-r--r-- 1 inoue inoue 245 10月 1 1998 hello.html
-rw-r--r-- 1 inoue inoue 81 10月 1 1998 policy
[inoue@onlsbc1 JavaRMI]$
パッケージのディレクトリ構成に合わせるために、getStartディレクトリの下に
examples/hello のディレクトリを作成し、上で展開した全ファイルをそこに
配置する。 結果は以下のとうり。
[inoue@onlsbc1 hello]$ pwd
/home/inoue/JavaRMI/getStart/examples/hello
[inoue@onlsbc1 hello]$ ls -l
合計 10
-rw-r--r-- 1 inoue inoue 1998 1月 26 2002 Hello.java
-rw-r--r-- 1 inoue inoue 2574 1月 26 2002 HelloApplet.java
-rw-r--r-- 1 inoue inoue 2779 1月 26 2002 HelloImpl.java
-rw-r--r-- 1 inoue inoue 245 10月 1 1998 hello.html
-rw-r--r-- 1 inoue inoue 81 10月 1 1998 policy
[inoue@onlsbc1 hello]$
手順としては、*.java ソースファイルをコンパイルして、.class ファイルを
作成する。 その後、rmic コンパイラを実行してスタブとスケルトンを作成する
ことになる。
javac や rmic コンパイラを使うときは、生成されるクラスファイルをどの
ディレクトリに置くかを指定しなければならない。 アプレットの場合には、
すべてのファイルをアプレットのコードベースディレクトリに置く必要がある。
この例では、コードベースディレクトリは、
onlsbc1:$HOME/public_html/myclasses
になる。
(1-3-1). ランタイムパスを設定する
[inoue@onlsbc1 inoue]$ export CLASSPATH=.:$HOME/public_html/myclasses:$HOME/Java
RMI/getStart/examples/hello
[inoue@onlsbc1 inoue]$ printenv CLASSPATH
.:/home/inoue/public_html/myclasses:/home/inoue/JavaRMI/getStart/examples/hello
[inoue@onlsbc1 inoue]$
[inoue@onlsbc1 inoue]$ mkdir -p public_html/myclasses
[inoue@onlsbc1 inoue]$ cd public_html/myclasses
[inoue@onlsbc1 myclasses]$ pwd
/home/inoue/public_html/myclasses
[inoue@onlsbc1 myclasses]$ ls -l
合計 0
[inoue@onlsbc1 myclasses]$
(1-3-2). ソースファイルをコンパイルする
[inoue@onlsbc1 hello]$ pwd
/home/inoue/JavaRMI/getStart/examples/hello
[inoue@onlsbc1 hello]$ ls -l
合計 10
-rw-r--r-- 1 inoue inoue 1998 1月 26 2002 Hello.java
-rw-r--r-- 1 inoue inoue 2574 1月 26 2002 HelloApplet.java
-rw-r--r-- 1 inoue inoue 2779 1月 26 2002 HelloImpl.java
-rw-r--r-- 1 inoue inoue 245 10月 1 1998 hello.html
-rw-r--r-- 1 inoue inoue 81 10月 1 1998 policy
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ cat Hello.java
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* -Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
* EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
* DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
* RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
* ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
* FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
* THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that Software is not designed, licensed or
* intended for use in the design, construction, operation or
* maintenance of any nuclear facility.
*/
package examples.hello;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ cat HelloApplet.java
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* -Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
* EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
* DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
* RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
* ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
* FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
* THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that Software is not designed, licensed or
* intended for use in the design, construction, operation or
* maintenance of any nuclear facility.
*/
package examples.hello;
import java.applet.Applet;
import java.awt.Graphics;
import java.rmi.Naming;
import java.rmi.RemoteException;
public class HelloApplet extends Applet {
String message = "blank";
// "obj" is the identifier that we'll use to refer
// to the remote object that implements the "Hello"
// interface
Hello obj = null;
public void init() {
try {
obj = (Hello)Naming.lookup("//" +
getCodeBase().getHost() + "/HelloServer");
message = obj.sayHello();
} catch (Exception e) {
System.out.println("HelloApplet exception: " +
e.getMessage());
e.printStackTrace();
}
}
public void paint(Graphics g) {
g.drawString(message, 25, 50);
}
}
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ cat HelloImpl.java
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* -Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
* EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
* DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
* RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
* ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
* FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
* THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that Software is not designed, licensed or
* intended for use in the design, construction, operation or
* maintenance of any nuclear facility.
*/
package examples.hello;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject
implements Hello {
public HelloImpl() throws RemoteException {
super();
}
public String sayHello() {
return "Hello World!";
}
public static void main(String args[]) {
// Create and install a security manager
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
HelloImpl obj = new HelloImpl();
// Bind this object instance to the name "HelloServer"
Naming.rebind("HelloServer", obj);
System.out.println("HelloServer bound in registry");
} catch (Exception e) {
System.out.println("HelloImpl err: " + e.getMessage());
e.printStackTrace();
}
}
}
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ cat hello.html
<HTML>
<title>Hello World</title>
<center> <h1>Hello World</h1> </center>
The message from the HelloServer is:
<p>
<applet codebase="myclasses/"
code="examples.hello.HelloApplet"
width=500 height=120>
</applet>
</HTML>
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ javac -d $HOME/public_html/myclasses Hello.java HelloImpl
.java HelloApplet.java
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ ls -lR $HOME/public_html/myclasses
/home/inoue/public_html/myclasses:
合計 1
drwxrwxr-x 3 inoue inoue 1024 10月 22 13:38 examples
/home/inoue/public_html/myclasses/examples:
合計 1
drwxrwxr-x 2 inoue inoue 1024 10月 22 13:38 hello
/home/inoue/public_html/myclasses/examples/hello:
合計 5
-rw-rw-r-- 1 inoue inoue 224 10月 22 13:38 Hello.class
-rw-rw-r-- 1 inoue inoue 1284 10月 22 13:38 HelloApplet.class
-rw-rw-r-- 1 inoue inoue 1247 10月 22 13:38 HelloImpl.class
[inoue@onlsbc1 hello]$
(1-3-3). rmic を使ってスタブおよびスケルトンを生成する
[inoue@onlsbc1 hello]$ pwd
/home/inoue/JavaRMI/getStart/examples/hello
[inoue@onlsbc1 hello]$ ls -l
合計 10
-rw-r--r-- 1 inoue inoue 1998 1月 26 2002 Hello.java
-rw-r--r-- 1 inoue inoue 2574 1月 26 2002 HelloApplet.java
-rw-r--r-- 1 inoue inoue 2779 1月 26 2002 HelloImpl.java
-rw-r--r-- 1 inoue inoue 245 10月 1 1998 hello.html
-rw-r--r-- 1 inoue inoue 81 10月 1 1998 policy
[inoue@onlsbc1 hello]$ rmic -d $HOME/public_html/myclasses examples.hello.HelloI
mpl
[inoue@onlsbc1 hello]$
[inoue@onlsbc1 hello]$ ls -lR $HOME/public_html/myclasses
/home/inoue/public_html/myclasses:
合計 1
drwxrwxr-x 3 inoue inoue 1024 10月 22 13:38 examples
/home/inoue/public_html/myclasses/examples:
合計 1
drwxrwxr-x 2 inoue inoue 1024 10月 22 13:46 hello
/home/inoue/public_html/myclasses/examples/hello:
合計 10
-rw-rw-r-- 1 inoue inoue 224 10月 22 13:38 Hello.class
-rw-rw-r-- 1 inoue inoue 1284 10月 22 13:38 HelloApplet.class
-rw-rw-r-- 1 inoue inoue 1247 10月 22 13:38 HelloImpl.class
-rw-rw-r-- 1 inoue inoue 1448 10月 22 13:46 HelloImpl_Skel.class
-rw-rw-r-- 1 inoue inoue 2920 10月 22 13:46 HelloImpl_Stub.class
[inoue@onlsbc1 hello]$
(1-3-4). HTML ファイルを配置ディレクトリに移す
[inoue@onlsbc1 hello]$ pwd
/home/inoue/JavaRMI/getStart/examples/hello
[inoue@onlsbc1 hello]$ ls -l
合計 10
-rw-r--r-- 1 inoue inoue 1998 1月 26 2002 Hello.java
-rw-r--r-- 1 inoue inoue 2574 1月 26 2002 HelloApplet.java
-rw-r--r-- 1 inoue inoue 2779 1月 26 2002 HelloImpl.java
-rw-r--r-- 1 inoue inoue 245 10月 1 1998 hello.html
-rw-r--r-- 1 inoue inoue 81 10月 1 1998 policy
[inoue@onlsbc1 hello]$ cp hello.html $HOME/public_html
[inoue@onlsbc1 hello]$ ls -l $HOME/public_html/hello.html
-rw-r--r-- 1 inoue inoue 245 10月 22 13:49 /home/inoue/public_html
/hello.html
[inoue@onlsbc1 hello]$
(2). RMI レジストリ、サーバの起動
(2-1). Apache Webサーバを起動
Apache Webサーバの設定ファイルは /etc/httpdディレクトリ下に配置されて
いる。 この設定ファイルの再構築および apache実行時に必要とされる関連
ディレクトリやファイルは /var/www/htmlディレクトリ下に配置される。
Apache設定ファイルの再構築は、apacheconfコマンドを実行することで行う。
apacheconfコマンドは rootの権限で X Window System の下で実行する。
(2-1-1). apacheconf のチェック
[inoue@onlsbc1 hello]$ which apacheconf
/usr/bin/which: no apacheconf in (/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/u
sr/java/bin:/home/inoue/bin)
[inoue@onlsbc1 hello]$
コンパクトフラッシュ上のLinuxシステムには、Xをインストールしていないので
apacheconf を利用できない。 手動で apacheの設定をする必要がある。 conf
ファイルの設定を全く最初から整備するのも大変なのでその方法はとらない。
以前、onlsbc1の2.5"ハードディスク上に構成した apacheの confファイルを
ベースにし、必要ならばファイルの内容を修正して構築することにする。
したがって、ここで一旦、コンパクトフラッシュ上のLinuxシステムをシャット
ダウンし、2.5"ハードディスクのシステムを立ち上げて作業を行う。
[root@onlsbc1 conf]# /sbin/shutdown -h now
Broadcast message from root (pts/0) (Tue Oct 22 15:26:32 2002):
The system is going down for system halt NOW!
[root@onlsbc1 conf]#
(2-1-2). 2.5"ハードディスクシステム上のコンフィグレーション設定をチェック
チェック1: 2.5"ハードディスクシステムの /etc/httpd
[root@onlsbc1 httpd]# pwd
/etc/httpd
[root@onlsbc1 httpd]# ls -lR
.:
合計 4
drwxr-xr-x 7 root root 4096 9月 18 10:24 conf
lrwxrwxrwx 1 root root 19 9月 18 10:17 logs -> ../../var/log/h
ttpd
lrwxrwxrwx 1 root root 21 9月 18 10:17 modules -> ../..//usr/l
ib/apache
./conf:
合計 100
lrwxrwxrwx 1 root root 37 9月 18 10:24 Makefile -> ../../../us
r/share/ssl/certs/Makefile
-rw-r--r-- 1 root root 285 6月 20 00:55 access.conf
-rw-r--r-- 1 root root 51270 6月 20 00:55 httpd.conf
-rw-r--r-- 1 root root 12441 6月 20 00:55 magic
-rw-r--r-- 1 root root 297 6月 20 00:55 srm.conf
drwx------ 2 root root 4096 9月 18 10:24 ssl.crl
drwx------ 2 root root 4096 9月 18 10:24 ssl.crt
drwx------ 2 root root 4096 7月 2 05:43 ssl.csr
drwx------ 2 root root 4096 9月 18 10:24 ssl.key
drwx------ 2 root root 4096 9月 18 10:24 ssl.prm
./conf/ssl.crl:
合計 4
-rw-r--r-- 1 root root 1569 7月 2 05:43 Makefile.crl
./conf/ssl.crt:
合計 268
-rw-r--r-- 1 root root 1522 7月 2 05:43 Makefile.crt
-rw-r--r-- 1 root root 242153 7月 2 05:43 ca-bundle.crt
-rw------- 1 root root 1464 8月 21 03:39 server.crt
-rw-r--r-- 1 root root 1472 7月 2 05:43 snakeoil-ca-dsa.crt
-rw-r--r-- 1 root root 1192 7月 2 05:43 snakeoil-ca-rsa.crt
-rw-r--r-- 1 root root 1452 7月 2 05:43 snakeoil-dsa.crt
-rw-r--r-- 1 root root 1176 7月 2 05:43 snakeoil-rsa.crt
./conf/ssl.csr:
合計 0
./conf/ssl.key:
合計 20
-rw------- 1 root root 887 8月 21 03:39 server.key
-rw------- 1 root root 668 7月 2 05:43 snakeoil-ca-dsa.key
-rw------- 1 root root 887 7月 2 05:43 snakeoil-ca-rsa.key
-rw------- 1 root root 668 7月 2 05:43 snakeoil-dsa.key
-rw------- 1 root root 891 7月 2 05:43 snakeoil-rsa.key
./conf/ssl.prm:
合計 8
-rw-r--r-- 1 root root 455 7月 2 05:43 snakeoil-ca-dsa.prm
-rw-r--r-- 1 root root 455 7月 2 05:43 snakeoil-dsa.prm
[root@onlsbc1 httpd]#
チェック2: コンパクトフラッシュシステムの /etc/httpd
[root@onlsbc1 httpd]# pwd
/mnt1/etc/httpd
[root@onlsbc1 httpd]# ls -lR
.:
合計 1
drwxr-xr-x 2 root root 1024 10月 22 14:56 conf
lrwxrwxrwx 1 root root 19 10月 17 23:27 logs -> ../../var/log/h
ttpd
lrwxrwxrwx 1 root root 21 10月 17 23:27 modules -> ../..//usr/l
ib/apache
./conf:
合計 68
-rw-r--r-- 1 root root 285 4月 10 2002 access.conf
-rw-r--r-- 1 root root 51270 4月 10 2002 httpd.conf
-rw-r--r-- 1 root root 12441 4月 10 2002 magic
-rw-r--r-- 1 root root 297 4月 10 2002 srm.conf
[root@onlsbc1 httpd]#
/etc/httpd/conf 下のファイルをチェックする。
[root@onlsbc1 conf]# pwd
/mnt1/etc/httpd/conf
[root@onlsbc1 conf]# ls -l
合計 68
-rw-r--r-- 1 root root 285 4月 10 2002 access.conf
-rw-r--r-- 1 root root 51270 4月 10 2002 httpd.conf
-rw-r--r-- 1 root root 12441 4月 10 2002 magic
-rw-r--r-- 1 root root 297 4月 10 2002 srm.conf
[root@onlsbc1 conf]# diff httpd.conf /etc/httpd/conf/httpd.conf
[root@onlsbc1 conf]# diff magic /etc/httpd/conf/magic
[root@onlsbc1 conf]# diff access.conf /etc/httpd/conf/access.conf
[root@onlsbc1 conf]# diff srm.conf /etc/httpd/conf/srm.conf
[root@onlsbc1 conf]#
/etc/httpd/conf 下のファイルの内容は、2.5"ハードディスク上のLinuxシステ
ムとコンパクトフラッシュ上のLinuxシステムの場合とで違いは無い。 つまり
2.5"ハードディスク上のLinuxシステムにおいても apacheconf による再構築で
変更するようなことはしていないということになる。 コンパクトフラッシュ上
のLinuxシステムも変更は行わないでこのままにしておく。
チェック1: 2.5"ハードディスクシステムの /var/www
[root@onlsbc1 www]# pwd
/var/www
[root@onlsbc1 www]# ls -l
合計 12
drwxr-xr-x 2 root root 4096 6月 20 00:55 cgi-bin
drwxr-xr-x 5 root root 4096 9月 18 10:17 html
drwxr-xr-x 3 root root 4096 9月 18 10:17 icons
[root@onlsbc1 www]# ls -l html
合計 20
-rw-r--r-- 1 root root 2890 6月 20 00:55 index.html
drwxr-xr-x 3 root root 4096 8月 21 03:39 manual
drwxr-xr-x 2 root root 4096 8月 21 03:39 mrtg
-rw-r--r-- 1 root root 1154 6月 20 00:55 poweredby.png
drwxr-xr-x 2 root root 4096 8月 21 03:40 usage
[root@onlsbc1 www]#
チェック2: コンパクトフラッシュシステムの /mnt1/var/www
[root@onlsbc1 www]# pwd
/mnt1/var/www
[root@onlsbc1 www]# ls -l
合計 5
drwxr-xr-x 2 root root 1024 4月 10 2002 cgi-bin
drwxr-xr-x 2 root root 1024 10月 17 23:27 html
drwxr-xr-x 3 root root 3072 10月 17 23:27 icons
[root@onlsbc1 www]# ls -l html
合計 5
-rw-r--r-- 1 root root 2890 4月 10 2002 index.html
-rw-r--r-- 1 root root 1154 4月 10 2002 poweredby.png
[root@onlsbc1 www]#
コンパクトフラッシュシステムでも、www で必要なファイルはインストール時に
すでに配置されている。
(2-1-3). コンパクトフラッシュ上に Apache設定を構成
コンパクトフラッシュ上にLinuxシステムシステムをインストールした時に設定
された標準設定のままで Apacheを起動する。
(2-1-4). コンパクトフラッシュ上のApache Webサーバを起動
[root@onlsbc1 inoue]# /sbin/service httpd start
httpdを起動中: [ OK ]
[root@onlsbc1 inoue]#
[root@onlsbc1 inoue]# ps -ef | grep httpd
root 1139 1 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1142 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1143 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1144 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1145 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1146 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1147 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1148 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1149 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
root 1152 1093 0 10:27 pts/0 00:00:00 grep httpd
[root@onlsbc1 inoue]#
ok. 正常に起動できた。
(2-1-5). ユーザディレクトリの設定
Red Hat Linux 7.3 の標準では、ユーザのホームディレクトリのパーミッション
は、ユーザのみが読み書きおよび実行可能になっている。 これでは、ユーザ
ディレクトリ下の public_htmlディレクトリーに webブラウザでアクセスした
時にアクセス権がないと言われてしまう。 グループ、アザーズに読み出し、
実行のパーミッションを付ける。
[inoue@onlsbc1 home]$ pwd
/home
[inoue@onlsbc1 home]$ ls -l
合計 2
drwx------ 6 inoue inoue 1024 10月 23 10:39 inoue
drwx------ 2 yasu yasu 1024 10月 17 23:30 yasu
[inoue@onlsbc1 home]$ chmod go+rx inoue
[inoue@onlsbc1 home]$ ls -l
合計 2
drwxr-xr-x 6 inoue inoue 1024 10月 23 10:39 inoue
drwx------ 2 yasu yasu 1024 10月 17 23:30 yasu
[inoue@onlsbc1 home]$
(2-1-6). rmiregistry の起動
rmiregistry を起動する。
[inoue@onlsbc1 getStart]$ pwd
/home/inoue/JavaRMI/getStart
[inoue@onlsbc1 getStart]$ rmiregistry &
[1] 1163
[inoue@onlsbc1 getStart]$
[inoue@onlsbc1 getStart]$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 10:17 ? 00:00:04 init
root 2 1 0 10:17 ? 00:00:00 [keventd]
root 3 1 0 10:17 ? 00:00:00 [kapmd]
root 4 1 0 10:17 ? 00:00:00 [ksoftirqd_CPU0]
root 5 1 0 10:17 ? 00:00:00 [kswapd]
root 6 1 0 10:17 ? 00:00:00 [bdflush]
root 7 1 0 10:17 ? 00:00:00 [kupdated]
root 8 1 0 10:17 ? 00:00:00 [mdrecoveryd]
root 12 1 0 10:17 ? 00:00:00 [kjournald]
root 83 1 0 10:17 ? 00:00:00 [khubd]
root 637 1 0 10:18 ? 00:00:00 syslogd -m 0
root 642 1 0 10:18 ? 00:00:00 klogd -x
rpc 657 1 0 10:18 ? 00:00:00 portmap
root 743 1 0 10:18 ? 00:00:00 /usr/sbin/apmd -p 10 -w 5 -W -P
root 757 1 0 10:18 ? 00:00:01 /usr/sbin/sshd
root 778 1 0 10:18 ? 00:00:00 gpm -t ps/2 -m /dev/mouse
bin 791 1 0 10:18 ? 00:00:00 cannaserver -syslog -u bin -inet
root 803 1 0 10:18 ? 00:00:00 crond
daemon 827 1 0 10:18 ? 00:00:00 /usr/sbin/atd
root 834 1 0 10:18 ? 00:00:00 login -- inoue
root 835 1 0 10:18 tty2 00:00:00 /sbin/mingetty tty2
root 836 1 0 10:18 tty3 00:00:00 /sbin/mingetty tty3
root 837 1 0 10:18 tty4 00:00:00 /sbin/mingetty tty4
root 838 1 0 10:18 tty5 00:00:00 /sbin/mingetty tty5
root 839 1 0 10:18 tty6 00:00:00 /sbin/mingetty tty6
inoue 842 834 0 10:19 tty1 00:00:00 -bash
root 877 842 0 10:19 tty1 00:00:00 kon
inoue 881 877 0 10:19 ttyp0 00:00:00 -bash
root 1025 757 0 10:24 ? 00:00:00 /usr/sbin/sshd
inoue 1026 1025 0 10:24 pts/0 00:00:00 -bash
root 1139 1 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1142 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1143 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1144 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1145 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1146 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1147 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1148 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
apache 1149 1139 0 10:26 ? 00:00:00 /usr/sbin/httpd -DHAVE_ACCESS -D
inoue 1163 1026 20 10:49 pts/0 00:00:06 rmiregistry
inoue 1164 1163 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1165 1164 1 10:49 pts/0 00:00:00 rmiregistry
inoue 1166 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1167 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1168 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1169 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1170 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1171 1164 14 10:49 pts/0 00:00:03 rmiregistry
inoue 1173 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1174 1164 0 10:49 pts/0 00:00:00 rmiregistry
inoue 1175 1026 0 10:49 pts/0 00:00:00 ps -ef
[inoue@onlsbc1 getStart]$
ok. 正常に起動できた。
(4-1-3). サーバ の起動
サーバを起動する
[inoue@onlsbc1 getStart]$ ls -lR ~/public_html
/home/inoue/public_html:
合計 2
-rw-r--r-- 1 inoue inoue 245 10月 22 13:49 hello.html
drwxrwxr-x 3 inoue inoue 1024 10月 22 13:38 myclasses
/home/inoue/public_html/myclasses:
合計 1
drwxrwxr-x 3 inoue inoue 1024 10月 22 13:38 examples
/home/inoue/public_html/myclasses/examples:
合計 1
drwxrwxr-x 2 inoue inoue 1024 10月 22 13:46 hello
/home/inoue/public_html/myclasses/examples/hello:
合計 10
-rw-rw-r-- 1 inoue inoue 224 10月 22 13:38 Hello.class
-rw-rw-r-- 1 inoue inoue 1284 10月 22 13:38 HelloApplet.class
-rw-rw-r-- 1 inoue inoue 1247 10月 22 13:38 HelloImpl.class
-rw-rw-r-- 1 inoue inoue 1448 10月 22 13:46 HelloImpl_Skel.class
-rw-rw-r-- 1 inoue inoue 2920 10月 22 13:46 HelloImpl_Stub.class
[inoue@onlsbc1 getStart]$
[inoue@onlsbc1 getStart]$ java -Djava.rmi.server.codebase=http://onlsbc1.kek.jp/
~inoue/myclasses/ -Djava.security.policy=$HOME/JavaRMI/getStart/examples/hello/p
olicy examples.hello.HelloImpl
HelloServer bound in registry
(3). サーバのへのアクセス
(3-1). webブラウザ、IEを使ってサーバにアクセスした場合の実行結果
onlnote2.kek.jp のマシンから IE6.0を使ってサーバにアクセスする。
Webブラウザ、IEで "http://onlsbc1.kek.jp/~inoue/hello.html" に
アクセスすると、"Hello World!"と表示される。
(3-2). appletviewerを使ってサーバにアクセスした場合の実行結果
onlpara.kek.jp のマシンから appletviewerを使ってサーバにアクセスする。
[inoue@onlpara inoue]$ pwd
/home/inoue
[inoue@onlpara inoue]$ which appletviewer
/usr/java/bin/appletviewer
[inoue@onlpara inoue]$
[inoue@onlpara inoue]$ export DISPLAY=onlsun2:0
[inoue@onlpara inoue]$ appletviewer http://onlsbc1.kek.jp/~inoue/hello.html
Warning: Cannot convert string "-watanabe-mincho-medium-r-normal--*-140-*-*-c-*-jisx0208.1983-0" to type FontStruct
2002/10/23 14:43:12 java.util.prefs.FileSystemPreferences$3 run
警告: Could not create system preferences directory. System preferences are unusable.
ok. 正常に実行できた。
appletviewerで "http://onlsbc1.kek.jp/~inoue/hello.html" にアクセスする
と、"Hello World" と表示される。
---xxxx