作者 主題: 安裝 JSP ON FC3  (閱讀 1487 次)

0 會員 與 1 訪客 正在閱讀本文。

kowala

  • 憂鬱的高中生
  • ***
  • 文章數: 123
    • 檢視個人資料
安裝 JSP ON FC3
« 於: 2005-01-17 12:45 »
安裝測試 JSP ON FC3
製作:kowala 2005/01/17

###############################################
              安裝 JDK on FC3
###############################################
instjdk150.sh

請參考下方script
copy 下來與 jdk-1_5_0_01-linux-i586.rpm
放置同一目錄,並執行安裝。
要先改成可執行屬性
chmod +e instjdk150.sh
以下 script 義同上述

###############################################
           安裝 Tomcat 及 jk2
###############################################
inst-tomcat.sh
inst-jk2.sh

###############################################
        修改 /etc/httpd/conf/httpd.conf
###############################################
### Section 1: Global Environment
### Section 2: 'Main' server configuration
DocumentRoot "/usr/jakarta-tomcat-5.0.19/webapps"
#先把目錄指到tomcat根目錄去,才有JSP網頁可測試
### Section 3: Virtual Hosts

######################################################
      修改 /etc/httpd/conf/workers2.properties
######################################################
# add those under button of workers2.properties
[uri:/*.jsp]
worker=ajp13:localhost:8009

######################################################
 修改 /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
######################################################
增加下列
  <role rolename="admin"/>
  <role rolename="manager"/>
  <user username="abc" password="123456789" roles="admin,manager"/>
測試
重新啟動tomcat
在瀏覽器輸入
http://www.ore.com.tw:8080
點選左上的webadmin
登入 abc/123456789
######################################################
                     測試 JSP
######################################################

重新啟動 Apache
service httpd restart

開啟瀏覽器,並輸入
http://www.ore.com.tw/jsp-examples/num/numguess.jsp

玩個猜數字吧...

######################################################
                  建立 tomcat 服務
######################################################
建立服務啟動檔 tomcat
cp ./tomcat /etc/rc.d/init.d
chmod +x /etc/rc.d/init.d/tomcat
chkconfig --add tomcat
useradd tomcat
service tomcat restart
大功告成了

啟動檔 tomcat 內容
代碼: [選擇]

#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mmillson@meritonlinesystems.com>
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between RedHat Tomcat RPM and Chris Bush scripts

# Tomcat name :)
TOMCAT_PROG=tomcat
TOMCAT_HOME=/usr/jakarta-tomcat-5.0.19
# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
 TOMCAT_USER="tomcat"
fi

RETVAL=0

# start and stop functions
start() {
    echo -n "Starting tomcat: "
    chown -R $TOMCAT_USER:$TOMCAT_USER $TOMCAT_HOME/*
    chown -R $TOMCAT_USER:$TOMCAT_USER /home/tomcat/*
    su -l $TOMCAT_USER -c '$TOMCAT_HOME/bin/startup.sh'
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
    return $RETVAL
}

stop() {
    echo -n "Stopping tomcat: "
    su -l $TOMCAT_USER -c '$TOMCAT_HOME/bin/shutdown.sh'
    RETVAL=$?
    Echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid    
    rm -rf $TOMCAT_HOME/work/*
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 6
        start
        ;;
  *)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit $RETVAL



instjdk150.sh 內容

代碼: [選擇]

#################################################################
#                        安裝 jdk on FC3
# =============================================================
# 檔案名稱:instjdk150.sh
# 1. 修改 *.bin 檔案為可執行
# 2. 解壓縮出 *.rpm 至�{行目錄
# 3. copy *.rpm 到 /usr 目錄
# 4. 執行安裝 jdk
# 5. 建立連結檔,以供瀏覽器plugin
# 6. 建立 java 環境變數
# 7. 建立系統起始環境變數檔 /etc/profile.d/jsp.sh
#    改為由/root/download/tomcat554/inst-tomcat.sh 建立
# 使用:需先修改變數 jdkname=jdk-1_5_0_01-linux-i586-rpm.bin
# 製作:kowala 2005/01/04
#################################################################

jdkname=jdk-1_5_0_01-linux-i586-rpm.bin

echo "安裝檔案:$jdkname"

echo "變更為可執行屬性 ..."
chmod +x $jdkname

jdkrpm=${jdkname%-rpm.bin}.rpm
if test -f ./$jdkrpm; then
echo 刪除舊的 $jdkrpm ...
rm $jdkrpm
fi
echo 解出 RPM 檔 $jdkrpm ...
./$jdkname

if test -f /usr/$jdkrpm; then
echo 刪除舊的暫存 $jdkrpm ...
rm $jdkrpm
fi
echo 複製 $jdkrpm TO /usr
cp ./$jdkrpm /usr

echo 切換目錄 "/usr"
cd /usr

if test -d /usr/java/jdk1.5.0_01; then
echo 移除舊的安裝 jdk-1.5.0_01-fcs ...
rpm -e jdk-1.5.0_01-fcs
fi
echo 安裝 $jdkrpm ...
rpm -ivh $jdkrpm


echo 刪除暫存 $jdkrpm ...
rm $jdkrpm

if test -f /usr/lib/mozilla/plugins/libjavaplugin_oji.so; then
echo 刪除舊的連結檔 /usr/lib/mozilla/plugins/libjavaplugin_oji.so
rm /usr/lib/mozilla/plugins/libjavaplugin_oji.so
fi
echo 建立連結檔 Mozilla Plugin ...
ln -s /usr/java/jdk1.5.0_01/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so

echo �]定 java 環境參數 ...
#alternatives --remove <名稱> <路徑>
#alternatives --install <連結> <名稱> <路徑> <優先順序>
alternatives --remove java /usr/java/jdk1.5.0_01/bin/java
alternatives --install /usr/bin/java java /usr/java/jdk1.5.0_01/bin/java 5
echo 請選擇此項 : /usr/java/jdk1.5.0_01/bin/java
alternatives --config java
alternatives --display java
echo 測試 java ...
java
echo �]定 javac 環境參數 ...
alternatives --remove javac /usr/java/jdk1.5.0_01/bin/javac
alternatives --install /usr/bin/javac javac /usr/java/jdk1.5.0_01/bin/javac 6
echo 請選擇此項 : /usr/java/jdk1.5.0_01/bin/javac
alternatives --config javac
alternatives --display javac
echo 測試 javac ...
javac

# 建立系統起始環境變數檔 /etc/profile.d/jsp.sh ...
# echo 建立系統起始環境變數檔 /etc/profile.d/jsp.sh ...
echo 系統起始環境變數檔改為由/root/download/tomcat554/inst-tomcat.sh 建立!!!
#rm /etc/profile.d/jsp.sh
#echo JAVA_HOME=/usr/java/jdk1.5.0_01 >> /etc/profile.d/jsp.sh
#echo PATH=\$PATH:\$JAVA_HOME/bin >> /etc/profile.d/jsp.sh
#echo export JAVA_HOME PATH >> /etc/profile.d/jsp.sh
# �]定執行屬性
#echo �]定 /etc/profile.d/jsp.sh 執行屬性 ...
#chmod +x /etc/profile.d/jsp.sh
#echo jdk-1.5.0_01-fcs 安裝�]定完成,請重新登入,以使�]定值生效。


inst-tomcat.sh 內容

代碼: [選擇]

################################################################
#                    安裝 Tomcat on FC3
# =============================================================
# 檔案名稱:inst-tomcat.sh
# 1. 解壓縮 tomcatname=jakarta-tomcat-5.0.19.tar.gz
# 2. 檢查log目錄及檔案是否存在,否則建立。
# 3. 建立系統起始環境變數檔 /etc/profile.d/jsp.sh
# 4. 建立系統服務啟動檔 /etc/rc.d/init.d/tomcat
# 5. 新增管理員 /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
# 6. 啟動 tomcat 服務 service tomcat restart
#
# 使用:tomcatname=jakarta-tomcat-5.0.19.tar.gz
# 製作:kowala 2005/01/16
################################################################

tomcatname=jakarta-tomcat-5.0.19.tar.gz
CATALINA_HOME=/usr/jakarta-tomcat-5.0.19
#----------------------------------------------------
echo 解壓縮 jakarta-tomcat-5.0.19.tar.gz
if test -d $CATALINA_HOME ; then
printf "%s...\n" "目錄已存在 $tomcatname"
else
printf "%s...\n" "解壓縮 $tomcatname"
tar -xvzf $tomcatname -C /usr
fi
#----------------------------------------------------
printf "%s...\n" 檢查log目錄是否存在
if test -d $CATALINA_HOME/logs ; then
printf "%s...\n" "目錄 $CATALINA_HOME/logs 已經存在"
else
printf "%s...\n" "建立目錄 $CATALINA_HOME/logs"
mkdir $CATALINA_HOME/logs
fi
printf "%s...\n" 檢查log檔案是否存在
if test -f $CATALINA_HOME/logs/catalina.out ; then
printf "%s...\n" "紀錄檔 $CATALINA_HOME/logs/catalina.out 已經存在"
date > $CATALINA_HOME/logs/catalina.out
else
printf "%s...\n" "建立紀錄檔 $CATALINA_HOME/logs/catalina.out"
echo begin log at > $CATALINA_HOME/logs/catalina.out
date >> $CATALINA_HOME/logs/catalina.out
fi
cat $CATALINA_HOME/logs/catalina.out
#----------------------------------------------------
# 建立系統起始環境變數檔 /etc/profile.d/jsp.sh ...
echo 建立系統起始環境變數檔 /etc/profile.d/jsp.sh ...
echo JAVA_HOME=/usr/java/jdk1.5.0_01 > /etc/profile.d/jsp.sh
echo CATALINA_HOME=/usr/jakarta-tomcat-5.0.19 >> /etc/profile.d/jsp.sh
echo PATH=\$PATH:\$JAVA_HOME/bin >> /etc/profile.d/jsp.sh
echo export JAVA_HOME PATH CATALINA_HOME >> /etc/profile.d/jsp.sh
# �]定執行屬性
echo �]定 /etc/profile.d/jsp.sh 執行屬性 ...
chmod +x /etc/profile.d/jsp.sh
echo jdk-1.5.0_01-fcs and jakarta-tomcat-5.0.19 安裝�]定完成,請重新登入,以使�]定值生效。
echo 執行 jsp.sh �]定環境變數 ...
#/etc/profile.d/jsp.sh
#----------------------------------------------------
echo 建立系統服務啟動檔 /etc/rc.d/init.d/tomcat
# /etc/rc.d/init.d/tomcat
cp ./tomcat /etc/rc.d/init.d
chmod +x /etc/rc.d/init.d/tomcat
chkconfig --add tomcat
useradd tomcat
service tomcat restart

cat /etc/rc.d/init.d/tomcat
#----------------------------------------------------
# 新增管理員於 /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
#start an manager in tomcat-users.xml
echo "<?xml version='1.0' encoding='utf-8'?>" > /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo "<tomcat-users>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <role rolename=\"tomcat\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <role rolename=\"role1\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <role rolename=\"manager\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <role rolename=\"admin\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <user username=\"tomcat\" password=\"tomcat\" roles=\"tomcat\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <user username=\"both\" password=\"tomcat\" roles=\"tomcat,role1\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <user username=\"role1\" password=\"tomcat\" roles=\"role1\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo " <user username=\"abc\" password=\"123456789\" roles=\"admin,manager\"/>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
echo "</tomcat-users>" >> /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
# end of tomcat-users.xml
cat /usr/jakarta-tomcat-5.0.19/conf/tomcat-users.xml
#----------------------------------------------------
#重新啟動 Tomcat...
printf "%s...\n" "重新啟動 Tomcat..."
service tomcat restart


inst-jk2.sh 內容
下載
http://apache.stu.edu.tw/jakarta/tomcat-connectors/jk2/binaries/linux/Fedora-Core-1-i386.tar.gz
代碼: [選擇]

################################################################
#             安裝 Tomcat 結合 Arpache 連結器 on FC3
# =============================================================
# 檔案名稱:inst-jk2.sh
# 1. 下載安裝 http://apache.stu.edu.tw/jakarta/tomcat-connectors/jk2/binaries/linux/Fedora-Core-1-i386.tar.gz
# 2. 解壓縮 Fedora-Core-1-i386.tar.gz 到暫存目錄 /Fedora-Core-1-i386
# 3. 複製 jk2 到各所屬目錄
# 4. 刪除暫存目錄 /Fedora-Core-1-i386
# 5. 檢查各檔案已被安裝?
# 6. 顯示其他�]定訊息
#
# 使用:jk2=Fedora-Core-1-i386.tar.gz
# 製作:kowala 2005/01/16
################################################################
jk2=Fedora-Core-1-i386.tar.gz
d00=$jk2%.tar.gz

printf "%s...\n" "安裝 jakarta-tomcat-connectors-jk2 ..."
if test -d $d00 ; then
printf "%s\n" "$jk2 已安裝..."
else
printf "%s\n" "解壓縮 $jk2 到 /"
tar -xvzf $jk2 -C /
fi
#---------------------------------------
printf "%s\n" "複製 jk2 到 /etc..."
cp -a /$d00/etc/* /etc
printf "%s\n" "複製 jk2 到 /usr..."
cp -a /$d00/usr/* /usr
printf "%s\n" "複製 jk2 到 /var..."
cp -a /$d00/var/* /var
#---------------------------------------
printf "%s\n" "刪除暫存目錄 $d00/* ..."
rm -rf $d00
#---------------------------------------
# 檢查各檔案已被安裝?
f01=/etc/httpd/conf/workers2.properties
f02=/etc/httpd/conf.d/jk2.conf
f03=/usr/lib/httpd/modules/libjkjni.so
f04=/usr/lib/httpd/modules/mod_jk2.so
f05=/usr/share/doc/mod_jk2/CHANGES.txt
f06=/usr/share/doc/mod_jk2/LICENSE
f07=/usr/share/doc/mod_jk2/NOTICE
f08=/usr/share/doc/mod_jk2/README.txt
f09=/usr/share/doc/mod_jk2/STATUS.txt
d01=/var/www/manual/mod_jk2

printf "%s\n" "檢查 jakarta-tomcat-connectors-jk 是否完整安裝"
fmark=0

printf "%s" "checking $f01"
if test -f $f01 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=1
fi
printf "%s" "checking $f02"
if test -f $f02 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=2
fi
printf "%s" "checking $f03"
if test -f $f03 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=3
fi
printf "%s" "checking $f04"
if test -f $f04 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=4
fi
printf "%s" "checking $f05"
if test -f $f05 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=5
fi
printf "%s" "checking $f06"
if test -f $f06 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=6
fi
printf "%s" "checking $f07"
if test -f $f07 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=7
fi
printf "%s" "checking $f08"
if test -f $f08 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=8
fi
printf "%s" "checking $f09"
if test -f $f09 ; then
printf "%s\n" " 已安裝..."
else
printf "%s\n" " 不存在!!!"
fmark=9
fi
printf "%s" "checking $d01"
if test -d $d01 ; then
printf "%s\n" " 目錄已安裝..."
else
printf "%s\n" " 目錄不存在!!!"
fmark=10
fi
if test $fmark=0 ; then
printf "%s\n" "$jk2 安裝完成..."
else
printf "%s\n" "$jk2 安裝$[f$fmark]錯誤..."
fi
#---------------------------------------
# 顯示其他�]定訊息
printf "%s\n" "請修改下列檔案,新增以下資訊"
printf "%s\n" "新增以下資訊於 /etc/httpd/conf/workers2.properties"
printf "%s\n%s\n\n" "[uri:/*.jsp]" "worker=ajp13:localhost:8009"
printf "%s\n" "新增以下資訊於 /etc/httpd/conf/httpd.conf around line 300 "
printf "%s\n\n" "DocumentRoot \"/usr/jakarta-tomcat-5.0.19/webapps\""
printf "%s\n" "重新啟動 service httpd restart"
printf "%s\n\n" "�}啟瀏覽器,並輸入 http://www.ore.com.tw/jsp-examples/num/numguess.jsp"
printf "%s\n" "玩完猜數字遊戲後,表示 jk2 已正常運作,接著步驟是依需要�]定虛擬路徑了。"