ひょんなことで、C#.NETで作成したWindowsアプリケーションとTomcat5(Java)で作成したWebアプリケーションとのHTTP通信を行うシステムを作成したので、覚書します。
サーバ側は、テーブル及びビュー単位にSQL抽出クラスを準備して、
各メソッドは、必ずメッセージクラスを介して実行されるように作成していたので、今回の通信は、メッセージクラスを動的に呼び出すだけでできました。※よかったよかった
ですので、Tomcat(Java)側では、クラスとメソッドとフィールドを動的に判断しXMLデータを返すように作ってみました。
おかげで、Strutsの設定も1個だけでした。
今回は、クライアント側のプログラムだけ覚書します。
詳しい方はご指摘お願いしますね(w
なお、気になるサーバ側は次回覚書します。
<クライアント:C#側>
—————————————————————————-
■通信実行を指示するクラス
jp.seemo.xml.msg.XXXMLMsg : XMLデータセット
jp.seemo.xml.XXXMLFacility : 通信クラス
この2つのクラスを使って、サーバのクラスに対してメッセージを投げてみました。
サーバ側では、動的にクラスやメソッドを実行したいので、以下の様に実行してほしい機能を呼び出しました。
<xml_facility_class> : データベースからデータを抽出しXMLデータを生成するクラス
<xml_facility_method> : 実際に呼び出すメソッド
<xml_message> : やり取りするデータを表現する型
private jp.seemo.xml.msg.XXXMLMsg getList()
{
//通信メッセージの作成
jp.seemo.xml.msg.XXXMLMsg inMsg = new jp.seemo.xml.msg.XXXMLMsg();
//通信クラスを生成
jp.seemo.xml.XXXMLFacility xf = new jp.seemo.xml.XXXMLFacility(inMsg);
//通信実行
xf.execute(”<xml_facility_class>”, “<xml_facility_method>”, “<xml_message>”);
//レスポンスデータの取得
jp.seemo.xml.msg.XXXMLMsg bean = (jp.seemo.xml.msg.XXXMLMsg)xf.Items;
return bean;
}
—————————————————————————-
■XML通信を行うアブストラクトクラス
次のアブストラクト・クラスを継承して実際の通信処理を実装してみました。これでいちいち通信ロジックを書かなくてこれ一個でいけますね。
※コード内のTool.showSystemErrorは、システムエラーを簡易処理するメソッドです。
using System;
namespace jp.seemo.xml
{
public abstract class XMLFacility
{
protected System.Data.DataSet _items; //実際のキャリア
protected string class_name; //サーバのクラス名
protected string method_name; //サーバのメソッド名
protected string message_class; //サーバのメッセージ名
public XMLFacility(System.Data.DataSet inMsg)
{
this._items = inMsg; //送り側のメッセージ
}
public XMLFacility()
{}
/// <summary>
/// Java側で動的にクラス・メソッド・メッセージを選択する為に名称をセットしリクエストする
/// </summary>
/// <param name=”class_name”>クラス名</param>
/// <param name=”method_name”>メソッド名</param>
/// <param name=”message_class”>メッセージキャリア名</param>
public void execute(string class_name, string method_name, string message_class)
{
this.class_name = class_name;
this.method_name = method_name;
this.message_class = message_class;
httpRequest(); //実際の通信
}
/// <summary>
/// レスポンスデータを解析し、データをセットします。
/// </summary>
/// <param name=”resStream”></param>
protected void httpResponse(System.Xml.XmlTextReader resStream)
{
// XMLをリード
_items.Clear();
_items.ReadXml(resStream);
}
/// <summary>
/// 要求をPOSTし、結果をサーバから得ます。
/// </summary>
protected void httpRequest()
{
const string methodName = “httpRequest”;
System.IO.Stream reqStream = null;
System.Net.WebResponse res = null;
System.IO.Stream resStream = null;
System.IO.TextReader sr = null;
try
{
//バイト型配列に変換
byte[] postDataBytes = System.Text.Encoding.ASCII.GetBytes(postData());
//Requestの作成
System.Net.WebRequest req = System.Net.WebRequest.Create(”http://localhost:8080/xxxx/xmlf.do”);
req.Method = “POST”;
req.ContentType = “application/x-www-form-urlencoded”;
req.ContentLength = postDataBytes.Length;
reqStream = req.GetRequestStream();
reqStream.Write(postDataBytes, 0, postDataBytes.Length);
reqStream.Close();
//response
res = req.GetResponse();
resStream = res.GetResponseStream();
//受信して表示
sr = new System.IO.StreamReader(resStream, Tool.encode);
System.Xml.XmlTextReader tr = new System.Xml.XmlTextReader(sr);
//TEST
//Console.WriteLine(sr.ReadToEnd());
httpResponse(tr);
}
catch(Exception ex)
{
Tool.showSystemError(”XMLFacility”, methodName, ex);
}
finally
{
try
{
if (sr != null)
{
sr.Close();
}
}
catch(Exception ex)
{
Tool.showSystemError(”XMLFacility”, methodName, ex);
}
try
{
if (reqStream != null)
{
reqStream.Close();
}
}
catch(Exception ex)
{
Tool.showSystemError(”XMLFacility”, methodName, ex);
}
try
{
if (resStream != null)
{
resStream.Close();
}
}
catch(Exception ex)
{
Tool.showSystemError(”XMLFacility”, methodName, ex);
}
try
{
if (res != null)
{
res.Close();
}
}
catch(Exception ex)
{
Tool.showSystemError(”XMLFacility”, methodName, ex);
}
}
}
/// <summary>
/// レスポンスデータ
/// </summary>
public System.Data.DataSet Items
{
get
{
return this._items;
}
}
}
}
—————————————————————————-
■XMLFacility(通信用クラス)を継承して作成したクラス
POSTデータをセットして、送信するクラスを完成させます。
namespace jp.seemo.xml
{
/// <summary>
/// 通信ネタ(POSTデータ)を作成し、通信を行う
/// </summary>
public class XXXXMLFacility : XMLFacility
{
private string postData()
{
msg.XXXMLMsg inMsg = (msg.XXXMLMsg)Items;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int count = inMsg.row.Count;
sb.Append(”class_name=” + System.Web.HttpUtility.UrlEncode(this.class_name));
sb.Append(”&method_name=” + System.Web.HttpUtility.UrlEncode(this.method_name));
sb.Append(”&message_class=” + System.Web.HttpUtility.UrlEncode(this.message_class));
for (int i=0; i<count; i++)
{
sb.Append(”&user_id=” + System.Web.HttpUtility.UrlEncode(inMsg.row[i].user_id, Tool.encode));
sb.Append(”&password=” + System.Web.HttpUtility.UrlEncode(inMsg.row[i].password, Tool.encode));
}
string mystr = sb.ToString();
return mystr;
}
/// <summary>
/// リクエストメッセージを投入する
/// </summary>
/// <param name=”inMsg”></param>
public XXXXMLFacility(System.Data.DataSet inMsg): base(inMsg)
{}
public XXXXMLFacility(){}
}
}
以上です。
Posted by seemo as PROGRAM SAMPLE at 8:25 AM JST
No Comments »
RedhatES4を,インストールするとSubscription Numberを入力した後,Activateが失敗しませんか?
この原因と対処方法がわかったので,せっかくなので覚書します。
<原因>
RedhatES4でActivateする場合、「ハードウエア情報を送信する」にチェック
を付けると、レジストする際エラーが発生し、「エンタイトルメントがはずされ
ました」または「不明」といった情報で登録されるバグがあるようです。
http://www.jp.redhat.com/FAQ/index_rhnsub.html#2 のQ2
<対処方法>
1)誤った状態で登録されたシステム情報(System Profile)を削除する
2)再度、Activeteする(インストール後でも可能)
<手順>
1)https://www.redhat.com/apps/support/ でサブスクリプションが
有効期限内にあるか事をチェックする。
2)https://rhn.redhat.com からRHNにログインする。
3)全てのシステム一覧を参照すると次の様なメッセージのシステムが
登録されている。
①不明
②エンタイトルメントが外されました。
4)システムを選択し、右上の”delete system”をクリックする。
5)確認に対し、右下の「Delete Profile」ボタンをクリックする。
-問題のあるプロファイルをすべて削除したら、再度Activeteする-
6)%up2date –register #GUIが起動する
7)RedhatID, PASSWORDを入力する。
8)subscription number を入力する。
※ここで、ハードウエア情報の送信は、チェックを外す事!
サーバ名を入力する(ホスト名でいい)
9)表示されたチェンネルを確認し正しければ「進む」をクリックする。
※rpmヘッダをフェッチしています・・メッセージが続く(1時間~
10)全部終わるまでひたすら待ちます・・
-終わったら正しくRedhat Networksに登録された事を確認する-
11)全システムの更新のシステム記号に[レ]が表示されたらOK!
以上です。
Redhatからのメールもサイトも英語なので,くじけそうですが,エキサイト(http://www.excite.co.jp/world/)の優秀な翻訳のおかげで,なんとか解決しました。
ありがたやぁ~。
やっぱ,英語は大切ですね!
英語に慣れようと思って,昨日書店で,英語の「となりのトトロ」を買いました(w
Posted by seemo as SETUP MANUAL at 12:02 AM JST
No Comments »
ひょんなことで、
Excelで作成したcsvファイルを直接postgreSQLに投入する仕事があった時の話やけど・・
よく、DELIMITERを指定するサンプルがあるのですが、あれだと改行や , が含まれると、Excelから保存したてのほやほやファイルではエラーがでますよね。
意外とネットを探し回ってもDELIMITER指定するものばかりで、ぜんぜんうまくいかないんですよね・・・
改行やら区切り文字を変換するPG作るのも大変だし、なんか”さぁ~”っと入ってくれないかな~なんて、思いながらいろいろ調べていると、簡単な事でした(笑)
※でも、調べるのに相当時間がかかりました(涙)
今回も、せっかくなので覚書しておきます。
■postgreSQLへのデータ投入に関して
Excelで作成したCSVファイルは、shift_jisなので、
利用しているデータベースの文字コード(今回はutf-8)に合わせて、
文字コード変換が必要なんです。
知っとるわ~ って?
文字コード変換では、lvを利用しました。
RedhatES4は、初期ではその機能をもっていないので、
追加インストールしました。
なんで始めっから入ってないねん(愚痴
#ダウンロードする
% wget http://www.ff.iij4u.or.jp/~nrt/freeware/lv451.tar.gz
% tar xvfz lv451.tar.gz
% cd lv451/build
% ../src/configure
% make
% make install
#おしまい
▼データ投入手順
<対象データ>
テーブルに会わせた書式のデータをExcelで作成しcsv形式で保存したデータ
<手順>
1)Excel(CSV)保存
2)Redhatファイルシステムへ転送
3)UTF-8形式へ変換 (コマンド)
4)postgreSQLへ取込 (コマンド)
<コマンド>
#utf8へ変換
%lv -Ou8 file_shift_jis.csv > file_utf8.csv
#postgreSQLへ取込
%COPY table_name FROM ‘/file_system/file_name.csv’ CSV QUOTE ‘”‘;
テーブル名がtable01で、ファイル名がtest.csvで、保存場所が/usr/local/src だとすると、こんな感じです。
COPY table01 FROM ‘/usr/local/src/test.csv’ CSV QUOTE ‘”‘;
意外と知らなかったりしますよね。
また、lvは改行コードまで、\r\n -> \n に変えてくれてました。ありがたや~。
以上です。
Posted by seemo as PROGRAM SAMPLE at 12:00 AM JST
No Comments »
ひょんなことで、
この間インストールしたApacheを2.0.58から RedhatES4に標準で付いてくるApacheに入れ替えた(戻した)ときの話やけど・・
RedhatES4に標準Apache2.0.5x_xxにPHP5.16をインストールすると
./configureで、apxsが無いのでエラーになりました。
標準のApacheは、どうやら/etc/httpd/にインストールされるらしく
modules/ は、/usr/lib64/ に入っています。
で、どこを探してもapxsはないんですね。これが・・
なんでやねん・・・
PHPはこれがないとインストールできないし、困った困った。
1時間後ようやく、見つけました。
RedhatES4のCDの5枚目の中に、httpd-devel-2.0.59-9.ent.x86_64.rpmが・・
説明書くらい付けてよ・・(日本語で・・(大阪弁可
そんで、rpmでインストールするとエラーが2発!!
”あれとこれがないで” だって
あれ:apr-devel-0.9.4-24.1.x86_64.rpm
これ:apr-util-devel-0.9.4-17.x86_64.rpm
これらは、運よく同じ5枚目CDに入っていたので、先にインストールしてなんとかうまくいきました。
まったくLinuxは,いつもこんな調子で僕を困らせるので、楽しいですね(M?
せっかくなので手順を覚書します。
■RedhatES4標準ApacheをインストールしてPHPをインストールする為の準備。。
#RedhatES4の5枚目のCDに入っている次の3つのファイルを/usr/local/src にコピーします。
#apr-devel-0.9.4-24.1.x86_64.rpm
#apr-util-devel-0.9.4-17.x86_64.rpm
#httpd-devel-2.0.59-9.ent.x86_64.rpm
#続いて、インストールします。
%rpm -Uvh apr-devel-0.9.4-24.1.x86_64.rpm
%rpm -Uvh apr-util-devel-0.9.4-17.x86_64.rpm
%rpm -Uvh httpd-devel-2.0.59-9.ent.x86_64.rpm
#これで、PHPがインストールできるようになります。
#必要だったapxsは、次の場所にインストールされます。
#/usr/sbin/apxs
#なのでphpのコンパイルオプションには次のように記述するとOK。
#./configure –with-apxs2=/usr/sbin/apxs ・・・・・・
#なお、標準ApacheのHTTPドキュメントルートは、/var/www/html です。
#そこに<?php phpinfo(); ?> みたいなテストファイル作って実行すると,こんどは,
”warning: include_path=.:/usr/local/lib/php” みたいなのがでてOUT!!
まったく・・
まるで,pathの間違いかなみたいな気がするメッセージだけど,
そのファイルのパーミッション(実行権限)が不足していたのが原因でした。
#はぁ,Linuxやるまえに,NOVAにいったほうがいいかな・・ 英語・・
以上です。
覚書追加>>
▼サービスに登録する方法————————————–
%sed -e ’s/^# chkconfig:.*/# chkconfig: 2345 85 15/’
-e ’s/\/etc\/httpd/\/usr\/local\/httpd/’
-e ’s/\/usr\/sbin/\/usr\/local\/httpd\/bin/’ /usr/local/src/httpd-2.0.58/build/rpm/httpd.init > /etc/rc.d/init.d/httpd
%chmod 755 /etc/rc.d/init.d/httpd
%chkconfig –add httpd
%service http start
▲————————————————————
▼サービスに登録しないで起動する方法は次の通り—————-
%cd /etc/rc.d/
%vi rc.local
# 以下の文章を最後の行に追加する
———————————————-
/usr/local/httpd/bin/apachectl start
———————————————-
# 保存する。
#うまくいかないとき書式チェックする
%/usr/local/httpd/bin/apachectl configtest
Syntax OK
▲————————————————————-
# PCを再起動し、ブラウザからページが表示されるかテストします。
Posted by seemo as SETUP MANUAL at 12:35 PM JST
No Comments »
ひょんなことで、
Java+Strutsで、ファイルをアップロードする事になったので、
せっかくなので、その内容をポイントだけ覚書します。
ところで、ファイルアップロードする方法はいろいろあるけど、
ファイルのアップロードのタイミングってどうしてますか?
入力画面の後、確認ページを表示して、
最後の最後に、よかった時だけ、本当にUPしたいですよね。
なぜなら、一発目でUPすると、
確認ページでキャンセルされたとき、そのファイルは残っちゃうので、なんだかいやですよね。
そこでStrutsの、org.apache.struts.upload.FormFileっていう素敵なクラスを使って、最後に本当にUPしたい時にUPするプログラムを作りました。
この型のフィールドをActionFormにセットして、sessionで設定すると、複数個のファイルでも最後の最後に「登録」ボタンを押したときに、サーバに本当にUPする事ができましたよ。
詳しい方、ご指摘お願いしますね・・
1)ActionForm を作成する
import org.apache.struts.upload.FormFile;をインポートし、
private FormFile file;のようなフィールドを作成する。
submitすると勝手にファイルがActionFormに入ります。
複数ファイルを対応する場合は、
import java.util.List; のフィールドを作っておいてそこに、
submit時に現在formのファイル内容を保持するようにします。
XXForm bean= newXXForm();
bean.setFile(frm.getFile());
list.add(bean);
frm.setList(bean);
※このクラスには、コメントなど他の情報を乗せても平気です。
2)実際のアップロードは、確認ページの「登録」ボタンなどが押されたときのアクションで次のように取り出して、サーバーに保存します。
private void upload(XXForm frm, String root_path, String out_file_name) throws Exception {
FormFile fileUp = null;
InputStream is = null;
BufferedInputStream inBuffer= null;
FileOutputStream fos= null;
BufferedOutputStream outBuffer= null;
try{
fileUp = frm.getFile();
is = fileUp.getInputStream();
inBuffer = new BufferedInputStream(is);
fos = new FileOutputStream(root_path + “/” + out_file_name);
outBuffer = new BufferedOutputStream(fos);
int contents = 0;
while ((contents = inBuffer.read()) != -1) {
outBuffer.write(contents);
}
outBuffer.flush();
}finally{
if (outBuffer != null) {
try{
outBuffer.close();
}catch(Exception e){
//<エラーログ吐き出し処理>
}finally{
outBuffer = null;
}
}
if (fos != null) {
try{
fos.close();
}catch(Exception e){
//<エラーログ吐き出し処理>
}finally{
fos = null;
}
}
if (inBuffer != null) {
try{
inBuffer.close();
}catch(Exception e){
//<エラーログ吐き出し処理>
}finally{
inBuffer = null;
}
}
if (is != null) {
try{
is.close();
}catch(Exception e){
//<エラーログ吐き出し処理>
}finally{
is = null;
}
}
try{
fileUp.destroy();
}catch(Exception e){
//<エラーログ吐き出し処理>
}finally{
fileUp = null;
}
}
}
こんな風に簡単にできるのですが、なにせsessionに乗せるので、
ファイルの容量制限は、絶対にしないといけないし、
同じパソコン上で、タブブラウザを使ったり、「ファイル」から新しいWindowsを開いたりして同じ事をしようとすると,
sessionが重複しておかしくなるから、対策が必要ですよ~。
以上です。
Posted by seemo as PROGRAM SAMPLE at 9:09 AM JST
3 Comments »
またまた
ひょんなことで、RedhatES4.0に、PHPをインストールすることになりました。
せっかくなので、インストール手順を覚書します。
詳しい方、ご指摘お願いしますね・・
#は、コメントで、%は、コマンドプロンプトです。
ちなみに、こちらも、データベースはpostgreSQLです。
あ、文字コードはUTF-8です。
1.”PHP5.1.6″ is installed.
#”libxml” is needed wheny installing “PHP5″ in “RedhatES4.0.”
#Existence is checked.
%rpm -qa | grep libxml2
%cd /usr/local/src
%tar zxvf php-5.1.6.tar
%cd pho-5.1.6
%./configure –with-apxs2=/usr/local/httpd/bin/apxs –enable-mbstring
–enable-mbstr-enc-trans –enable-mbregex –enable-trans-sid –enable-zend-multibyte
–enable-track-vars –enable-exif –enable-ftp –enable-sockets
–with-pgsql=/usr/local/pgsql –without-mysql –enable-sqlite-utf8
%make
%make install
“php.ini” is edit
# sample file is copied.
%cp /usr/local/src/php-5.1.6/php.ini-dist /usr/local/lib/php.ini
%vi /usr/local/lib/php.ini
#”mbstring” is edit as follows.
——————————————
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = off
mbstring.detect_order = auto
mbstring.substitute_character = none
mbstring.func_overload = 0
——————————————
#”httpd.conf” is corrected.
——————————————
%vi /usr/local/httpd/conf/httpd.conf
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html #Arbitrary
LoadModule php5_module module/libphp5.so
——————————————
#Apache is rebooted.
%/usr/local/httpd/bin/apachectl restart
2.PHP is tested.
#The next file is created.
<?php phpinfo(); ?>
/usr/local/httpd/httpdoc/ <-copy here.
↑
#Please change “Web contener” into a suitable place later.
以上です。
Posted by seemo as SETUP MANUAL at 12:56 AM JST
Comments Off
ひょんな事で,Linuxサーバをインストールしたので,
せっかくなので,その時の手順です。
あちこちのサイトを参照しつつ,試行錯誤でできあがりました。
間違ってるところがあるかもしれないですが,
大体OKでしょ?
コメントの英語がめちゃくちゃですすみません。
そのうち正しく・・ なる・・ かも・・
fedora server install manual.
essential information.
ip address:xxx.xxx.xxx.xxx
sub netmask:xxxx.xxx.xxx.xxx (xx)
default gateway:xxx.xxx.xxx.xxx
dns1:xxx.xxx.xxx.xxx
dns2:xxx.xxx.xxx.xxx
host name:xxxxx
root password:xxxxxx
this server installs Fedora Core6 + Apache2.0.58 + Tomcat5.0.28(jdk1.4.2) + postgreSQL8.1.5.
Hardware is ML(cpu-64bit) of HP.
1.FEDORA is installed.
Please remove the web server and the data base from the package.
Moreover, please select the following package because it cannot be “make command”.
“Development package”, “Development of ..legacy.. software”, and “Development library”.
2.Installation of postgreSQL.
%groupadd postgres
%useradd -g postgres postgres
%password postgres
%chmod 777 /usr/local/src
%mkdir /usr/local/pgsql
%chown postgres.postgres /usr/local/pgsql
%su postgres
%cd /usr/local/src
%tar zxvf postgresql-8.1.5.tar.gz
%cd postgresql-8.1.5
%./configure –prefix=/usr/local/pgsql –enable-nls=ja
%make
%make install
“PostgreSQL installation complete” it ended correctly by this.
#making of environment variable
%vi ~/.bash_profile
———————————–
PGHOME=/usr/local/pgsql
PGDATA=$PGHOME/data
PGLIB=$PGHOME/lib
PATH=$PATH:$HOME/bin:$PGHOME/bin
export PGHOME PGDATA PGLIB PATH
———————————–
# save
%source ~/.bash_profile
%initdb –encoding=EUC_JP -no-locale
%exit
%vi /etc/ld.so.conf
#add it to the last line on a page.
———————————–
/usr/local/pgsql/lib
———————————–
# save
%cd /etc/
%ldconfig -v
%su - postgres
%vi /usr/local/pgsql/data/pg_hba.conf
# IPv4 local connections:
———————————————————————-
host all all 127.0.0.1/32 trush
host all all xxx.xxx.xxx.0/24 trust # add line
———————————————————————-
# save
%vi /usr/local/pgsql/data/postgresql.conf
# 「#listen_addresses=’localhost’」on line changes.
———————————————————————-
listen_addresses=’localhost,192.168.0.xx’ ・・・
# when it is possible to connect it from anywhere
listen_addresses=’*’
PORT=5432 #comment is removed.
———————————————————————-
# save
%pg_ctl start
or
%pg_ctl reload
%pg_ctl stop
# returns to the root.
%exit
# start script is copied.
%cd /usr/local/src/postgresql-8.1.5/contrib/start-scripts/
%cp linux /etc/rc.d/init.d/postgresql
# authority is set.
%cd /etc/rc.d/init.d/
%chmod 755 postgresql
# adds it to “service”.
%chkconfig –add postgresql
# postgresql start
%service postgresql start
# authority is without.
%chmod 755 /usr/local/src
4.Installation of Apache.
#ssl
%yum -y install openssl-devel
%mkdir /usr/local/httpd-2.0.58
%cd /usr/local/src
#64bitCPU onry
%up /usr/lib64/libexpat.so instead of /usr/lib
or
%cp /usr/lib64/libexpat.so /usr/lib
%tar zxvf httpd-2.0.58.tar.gz
%cd httpd-2.0.58
%./configure –prefix=/usr/local/httpd-2.0.58 –enable-rewrite=shared –without-ssl –without-dav_fs –without-dav
%make
%make install
#link
%ln -sfn /usr/local/httpd-2.0.58 /usr/local/httpd
#Apache Operation test
%/usr/local/httpd/bin/apachectl start
%/usr/local/httpd/bin/apachectl stop
#adds it to “service”.
%vi /usr/local/httpd/conf/httpd.conf
———————————————————————————————————
# LanguagePriority en ca cs da de el eo es et fr he hr it ha ja ko itz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
↓ja
LanguagePriority ja en ca cs da de el eo es et fr he hr it ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
———————————————————————————————————
%cd /etc/rc.d/
%vi rc.local
# last line add
———————————–
/usr/local/apache2/bin/apachectl start
———————————–
# save
# re check
%/usr/local/httpd/bin/apachectl configtest
Syntax OK
# pc restart.
5.Installation of Java.
#jdk1.4.2_13
% cd /usr/local/src
# cp j2sdk-1_4_2_13-linux-i586.bin /usr/local
# cd /usr/local
# chmod 755 j2sdk-1_4_2_13-linux-i586.bin
# ./j2sdk-1_4_2_13-linux-i586.bin
Sun Microsystems, Inc. Binary Code License Agreement
for the JAVA 2 PLATFORM STANDARD EDITION DEVELOPMENT
KIT 5.0
…..
For inquiries please contact: Sun Microsystems, Inc.,
4150 Network Circle, Santa Clara, California 95054,
U.S.A. (LFI#143333/Form ID#011801)
Do you agree to the above license terms? [yes or no]
yes ←entry
%ln -sfn /usr/local/j2sdk-1_4_2_13 /usr/local/jdk
6.Installation of Tomcat.
#download
wget -P /usr/local/src http://ftp.kddilabs.jp/infosystems/apache/tomcat/tomcat-5/v5.0.28/bin/jakarta-tomcat-5.0.28.tar.gz
%cd /usr/local/src
%tar xzf jakarta-tomcat-5.0.28.tar.gz -C /usr/local
%ln -sfn /usr/local/jakarta-tomcat-5.0.28 /usr/local/tomcat
7.Tomcat setting
%vi /etc/profile
———————————–
export JAVA_HOME=/usr/local/jdk
export CATALINA_HOME=/usr/local/tomcat
PATH=$PATH:$JAVA_HOME/bin
———————————–
#source
%source /etc/profile
#create user
%useradd -d /var/empty/tomcat -s /bin/bash tomcat
%chown -R tomcat:tomcat /usr/local/jakarta-tomcat-5.0.28
8.Tomcat testing
%su -s /bin/bash - tomcat -c “$CATALINA_HOME/bin/startup.sh”
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk
#add to “service”
#start script is copied.
%vi /etc/rc.d/init.d/tomcat
———————————————————————-
#!/bin/sh
#
# Startup script for the tomcat
#
# chkconfig: 345 80 15
# description: Tomcat
# Source function library.
. /etc/rc.d/init.d/functions
case “$1″ in
’start’)
if [ -f /usr/local/tomcat/bin/startup.sh ]; then
echo “Starting tomcat ..”
su - tomcat -c “export JAVA_HOME=/usr/local/jdk; \
export TOMCAT_HOME=/usr/local/tomcat;/usr/local/tomcat/bin/startup.sh”
fi
;;
’stop’)
echo “Stopping tomcat ..”
su - tomcat -c “export JAVA_HOME=/usr/local/jdk; \
export TOMCAT_HOME=/usr/local/tomcat;/usr/local/tomcat/bin/shutdown.sh”
;;
‘restart’)
$0 stop
$0 start
;;
‘jkconf’)
if [ -f /usr/local/tomcat/bin/startup.sh ]; then
echo “Generating Apache mod_jk config file. ”
su - tomcat -c “export JAVA_HOME=/usr/local/jdk; \
export TOMCAT_HOME=/usr/local/tomcat;/usr/local/tomcat/bin/startup.sh jkconf”
fi
;;
*)
echo “Usage: $0 {start|stop|restart|jkconf}”
;;
esac
exit 0
———————————————————————-
#authority is set.
%chmod 755 /etc/rc.d/init.d/tomcat
%chkconfig –add tomcat
#test
%service tomcat start
%service tomcat stop
%service tomcat restart
11.Tomcat synchronizes with Apache.
#download
%wget -P /usr/local/src http://www.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz
%tar xvfz jakarta-tomcat-connectors-jk2-src-current.tar.gz
%cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2
%./configure –with-apxs2=/usr/local/apache2/bin/apxs
%make
%cp ../build/jk2/apache2/mod_jk2.so /usr/local/apache2/modules
#/usr/local/httpd/conf/httpd.conf
%LoadModule jk2_module modules/mod_jk2.so
#/usr/local/httpd/conf/workers2.properties create
%vi /usr/local/httpd/conf/workers2.properties
———————————–
[channel.socket:localhost:8009]
[shm:]
disabled=1
[uri:/jsp-exsamples/*]
———————————–
#conf/jk2.properties
%vi /usr/local/tomcat/conf/jk2.properties
———————————–
channelSocket.port=8009
———————————–
#edit server.xml
%vi /usr/local/tomcat/conf/server.xml
———————————————————————-
<Connector port=”8009″
enableLookups=”false” redirectPort=”8443″ debug=”0″
protocol=”AJP/1.3″ useBodyEncodingForURI=”true” />
———————————————————————-
#8080→7001 debug (Erase it at the end. )
———————————————————————-
<Connector port=”8080″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” redirectPort=”8443″ acceptCount=”100″
debug=”0″ connectionTimeout=”20000″
disableUploadTimeout=”true”
useBodyEncodingForURI=”true”/>
↓
<Connector port=”7001″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” redirectPort=”8443″ acceptCount=”100″
debug=”0″ connectionTimeout=”20000″
disableUploadTimeout=”true”
useBodyEncodingForURI=”true”/>
———————————————————————-
以上でした。
詳しい方が,いらっしゃいましたら,やばそうなとこ教えてください!!
よろしくお願いします。
Posted by seemo as SETUP MANUAL at 12:48 AM JST
Comments Off