練功房推薦書單

  • 猛虎出柙雙劍合璧版--最新 OCA / OCP Java SE 7 Programmer 專業認證 (電子書)
  • 流浪教師存零股存到3000萬(全新增修版)(書+DVD)
  • 開始在關西自助旅行(京都‧大阪‧神戶‧奈良)(全新增訂版)
  • 不敗教主的300張股票存股術

CentOS 5.2上Apache 2.2 + Tomcat 6 + JK 1.2自動化安裝程式 RSS feed
討論區首頁 » Application Server
發表人 內容
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 711
來自: 台北
離線
準備工作:
1.先安裝好CentOS 5.2 Linux作業系統,建議的硬碟分割配置如下:
SWAP 2.0G(RAM小於2G時可以設為RAM的兩倍)
/boot 100M
/ 2.0G
/usr 3.0G
/tmp 2.0G
/var 8.0G
/home 剩下來的部分

2.安裝完成後更新系統套件至最新版
yum -y update

3.安裝wget以便於後續的自動安裝動作
yum -y install wget

安裝Apache
1.安裝Apache套件
yum -y install httpd

2.取消SELinux,可以參考這篇http://www.crypt.gen.nz/selinux/disable_selinux.html
echo 0 >/selinux/enforce
sed -i -e "s/SELINUX=enforcing/SELINUX=disabled/" /etc/sysconfig/selinux

3.利用先前的設定檔產生設定修改部分(先將設定檔上傳再改名字為/tmp/httpd.conf.old)
diff /etc/httpd/conf/httpd.conf /tmp/httpd.conf.old > diff.txt
如果是第一次安裝,可以下載本站的diff.txt

44c44
< ServerTokens OS
---
> ServerTokens ProductOnly
74c74
< KeepAlive Off
---
> KeepAlive On
81c81
< MaxKeepAliveRequests 100
---
> MaxKeepAliveRequests 500
232c232
< Group apache
---
> Group tomcat
251c251
< ServerAdmin root@localhost
---
> ServerAdmin webmaster@your-domain.com
265a266
> ServerName 127.0.0.1:80
282c283
<
---
> VirtualDocumentRoot /var/webapps/%0
391c392
< DirectoryIndex index.html index.html.var
---
> DirectoryIndex sorry.html index.html index.htm default.html default.htm index.html.var index.jsp
488a490,491
> LogFormat "%V %h %l %u %t \"%r\" %>s %b" vcommon
> LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vcombined
492c495
< #LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
---
> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
514c517,518
< CustomLog logs/access_log combined
---
> CustomLog logs/access_log combinedio
> CustomLog logs/vhost.log vcombined
524c528
< ServerSignature On
---
> ServerSignature Off
747c751,752
< AddDefaultCharset UTF-8
---
> #AddDefaultCharset UTF-8
> AddDefaultCharset Big5
954a960,988
> <Location />
> # Insert filter
> SetOutputFilter DEFLATE
>

記得修改一下ServerAdmin的your-domain.com為真正的網域名稱

4.備份原始的httpd.conf設定檔
cp -rf /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig

5.套用設定檔的差異部分
yum install -y patch
patch -p2 /etc/httpd/conf/httpd.conf diff.txt

6.設定開機時自動啟動Apache
chkconfig --add httpd
chkconfig --level 35 httpd on

7.啟動Apache
service httpd start

安裝JDK
1.利用瀏覽器,至http://java.sun.com點選Popular Downloads:區塊中的Java SE,
2.然後點選JDK 6 Update 7旁的Download按鈕,
3.接下來在Platform:選擇Linux,然後勾選I agree to the Java SE Development Kit 6 License Agreement,按下Continue按鈕
4.在Java SE Development Kit 6u7下面的dk-6u7-linux-i586-rpm.bin連結上面按滑鼠右鍵,複製鏈結網址
5.然後切回到Linux的console畫面(假設是用PuTTY或PieTTY連上主機的),先輸入wget空一格然後打上一個雙引號",接著貼上剛剛複製的鏈結網址,然後再打上另一個雙引號",空一格後再打上-O jdk-6u7-linux-i586-rpm.bin,類似如下:
cd /root/setup/web
wget "http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u7-linux-i586-rpm.bin?BundledLineItemUUID=LaNIBe.n_FQAAAEcAC0b.noe&OrderID=5IFIBe.nqZUAAAEc8iwb.noe&ProductID=XzBIBe.oxM4AAAEaVJcGcbZW&FileName=/jdk-6u7-linux-i586-rpm.bin" -O jdk-6u7-linux-i586-rpm.bin
6.按下Enter後,便開始下載
7.然後用sh jdk-6u7-linux-i586-rpm.bin安裝它,可以利用echo 'yes'自動輸入畫面詢問的問題答案
echo 'yes'|sh jdk-6u7-linux-i586-rpm.bin

安裝Tomcat
1.下載本站的tomcat-setup.sh後,利用chmod 755 tomcat-setup.sh更改為可執行,如日後有軟體版本更新,請自行修正一些路徑或相關版本數字

#!/bin/bash
# Name: Tomcat 6.0.x auto installer
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 3.7
# Last Modified: 2008-09-19
# Reference: http://www.meritonlinesystems.com/docs/apache_tomcat_redhat.html
# Assumption: JDK must be installed on /usr/java
# This program will
# 1.check for the lastest stable version of Tomcat 6.0
# 2.download apache-tomcat-6.0.x.tar.gz
# 3.unpack it into /var/apache-tomcat-6.0.x
# 4.make a symbolic link /var/tomcat6 to the above directory for easy upgrade
# to a later version
# 5.check for the latest stable verion of Tomcat Connector 1.2
# 6.download tomcat-connectors-1.2.x-src.tar.gz
# 7.unpack it
# 8.configure, make and make install
# 9.create user tomcat with home directory /var/robust
# 10.make two instances of tomcat for load balancing, here I put them under
# /var/robust/worker[1,2] for easy to backup all of them.
# 11.generate cleanup.sh for easy to uninstall everything

#
# intranet workaround
# If your server don't have Internet access, ie. in the intranet behind
# a firewall, you have to download all the file manually first. Copy them
# into ${SETUP_FILE_PATH}. And then change the following default version
# number to the correct number you downloaded.
#
SETUP_FILE_PATH=/root/setup/web
TOMCAT_VERSION=6.0.18
TOMCAT_CONNECTOR_VERSION=1.2.26
LOG4J_VERSION=1.2.15
LOGGING_VERSION=1.1.1

hostname=`/bin/hostname`
mkdir -p ${SETUP_FILE_PATH}
cd ${SETUP_FILE_PATH}

#
# check the latest stable version of Tomcat 6.0
#
wget http://tomcat.apache.org/ -q -t 1 -T 5 -O /tmp/tomcat.html
if [ -s /tmp/tomcat.html ]; then
TOMCAT_VERSION=`grep "6\.0\." /tmp/tomcat.html|grep -v "6\.0\.x"|cut -d">" -f2|cut -d"<" -f1`
fi
rm -rf /tmp/tomcat.html

echo "Install Tomcat ${TOMCAT_VERSION}"
if [ ! -r apache-tomcat-${TOMCAT_VERSION}.tar.gz ]; then
wget http://apache.ntu.edu.tw/tomcat/tomcat-6/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz
fi
tar zxvf apache-tomcat-${TOMCAT_VERSION}.tar.gz -C /var
ln -s /var/apache-tomcat-${TOMCAT_VERSION} /var/tomcat6

echo 'rm -rf /var/apache-tomcat-'${TOMCAT_VERSION} > ${SETUP_FILE_PATH}/cleanup.sh
echo 'rm -rf /var/tomcat6' >> ${SETUP_FILE_PATH}/cleanup.sh

JDK_VERSION=`ls /usr/java | grep jdk`
echo "Use $JDK_VERSION"
echo 'JAVA_HOME="/usr/java/'${JDK_VERSION}'"
JAVA_OPTS="-server -XX:NewSize=64m -XX:MaxNewSize=64m -XX:MaxPermSize=128m -Xms1024m -Xmx1024m -Djava.awt.headless=true"' > /var/tomcat6/bin/setenv.sh
chmod 755 /var/tomcat6/bin/setenv.sh

#
# check the latest stable version of Tomcat Connector 1.2
#
# pre-requirment
yum -y install httpd-devel libtool automake make

wget http://tomcat.apache.org/download-connectors.cgi -q -t 1 -T 5 -O /tmp/connector.html
if [ -s /tmp/connector.html ]; then
TOMCAT_CONNECTOR_VERSION=`grep "1\.2\." /tmp/connector.html|cut -d">" -f2|cut -d"<" -f1 |awk '{print $2}'|grep "1.2"|uniq`
fi
rm -rf /tmp/connector.html
echo "Install Tomcat Connector JK ${TOMCAT_CONNECTOR_VERSION}"
if [ ! -r tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz ]; then
wget http://apache.ntu.edu.tw/tomcat/tomcat-connectors/jk/source/jk-${TOMCAT_CONNECTOR_VERSION}/tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz
fi
tar zxvf tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src.tar.gz
cd tomcat-connectors-${TOMCAT_CONNECTOR_VERSION}-src/native
./buildconf.sh
./configure --with-apxs=/usr/sbin/apxs
make
make install
cd ${SETUP_FILE_PATH}
echo 'rm -rf /etc/httpd/modules/mod_jk.so' >> ${SETUP_FILE_PATH}/cleanup.sh

#
# check the latest stable version of Log4J
#
wget http://logging.apache.org/log4j/1.2/download.html -q -t 1 -T 5 -O /tmp/log4j.html
if [ -s /tmp/log4j.html ]; then
LOG4J_VERSION=`grep "1\.2\." /tmp/log4j.html|cut -d"<" -f3|cut -d">" -f2|awk '{print $4}'`
fi
rm -rf /tmp/log4j.html
echo "Install Log4J ${LOG4J_VERSION}"
if [ ! -r logging-log4j-${LOG4J_VERSION}.tar.gz ]; then
wget http://apache.ntu.edu.tw/logging/log4j/${LOG4J_VERSION}/apache-log4j-${LOG4J_VERSION}.tar.gz
fi
tar zxvf apache-log4j-${LOG4J_VERSION}.tar.gz
cp -rf ${SETUP_FILE_PATH}/apache-log4j-${LOG4J_VERSION}/log4j-${LOG4J_VERSION}.jar /var/tomcat6/lib

#
# check the latest stable version of Commons - Logging
#
wget http://commons.apache.org/logging/ -q -t 1 -T 5 -O /tmp/logging.html
if [ -s /tmp/logging.html ]; then
LOGGING_VERSION=`grep "Release" /tmp/logging.html | grep -v "2006"|cut -d ">" -f5|cut -d"<" -f1|awk '{print $1}'|grep "1.1"`
fi
rm -rf /tmp/logging.html
echo "Install Commons - Logging ${LOGGING_VERSION}"
if [ ! -r commons-logging-${LOGGING_VERSION}-bin.tar.gz ]; then
wget http://apache.ntu.edu.tw/commons/logging/binaries/commons-logging-${LOGGING_VERSION}-bin.tar.gz
fi
tar zxvf commons-logging-${LOGGING_VERSION}-bin.tar.gz
cp -rf ${SETUP_FILE_PATH}/commons-logging-${LOGGING_VERSION}/commons-logging-${LOGGING_VERSION}.jar /var/tomcat6/lib

#
# generate log4j.properties
#
echo 'log4j.rootLogger=WARN, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/robust/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{DATE} - %p %c - %m%n
log4j.logger.org.apache.catalina=WARN, R' > /var/tomcat6/lib/log4j.properties

#
# add user tomcat
#
useradd tomcat -d /var/robust
echo 'userdel -r tomcat' >> ${SETUP_FILE_PATH}/cleanup.sh

#
# setup workers' directory
#
mkdir -p /var/robust/worker1/logs
mkdir -p /var/robust/worker1/temp
mkdir -p /var/robust/worker1/work
cp -rf /var/tomcat6/conf /var/robust/worker1/conf
mkdir -p /var/webapps
ln -s /var/webapps /var/robust/worker1/webapps
cp -rf /var/robust/worker1 /var/robust/worker2

#
# setup default host directory
#
mkdir -p /var/webapps/${hostname}
cp -rf /var/tomcat6/webapps/ROOT/* /var/webapps/${hostname}/.
mkdir -p /var/robust/worker1/conf/Catalina/${hostname}
mkdir -p /var/robust/worker2/conf/Catalina/${hostname}
cp -rf /var/tomcat6/webapps/host-manager/manager.xml /var/robust/worker1/conf/Catalina/${hostname}
cp -rf /var/tomcat6/webapps/host-manager/manager.xml /var/robust/worker2/conf/Catalina/${hostname}

#
# generate server.xml
#
echo '<Server port="workerPort" shutdown="shutdownCode">

<GlobalNamingResources>
<!-- Used by Manager webapp -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<Service name="Catalina">
<!-- Define an AJP 1.3 Connector on port ajpPort -->
<Connector port="ajpPort" address="127.0.0.1"
enableLookups="false" maxThreads="1000"
protocol="AJP/1.3" />

<Engine jvmRoute="workerNo" name="Catalina"
defaultHost="mydomain">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />' > /tmp/server.header.template

sed -e "s/workerPort/8105/g" -e "s/shutdownCode/`head -1024c /dev/urandom | md5sum | cut -d " " -f1`/g" -e "s/ajpPort/8109/g" -e "s/workerNo/worker1/g" -e "s/mydomain/${hostname}/g" /tmp/server.header.template > /var/robust/worker1/conf/server.header
sed -e "s/workerPort/8205/g" -e "s/shutdownCode/`head -1024c /dev/urandom | md5sum | cut -d " " -f1`/g" -e "s/ajpPort/8209/g" -e "s/workerNo/worker2/g" -e "s/mydomain/${hostname}/g" /tmp/server.header.template > /var/robust/worker2/conf/server.header
rm -rf /tmp/server.header.template

echo ' <Host name="'${hostname}'"
appBase="webapps/'${hostname}'"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="'${hostname}'_access_log."
suffix=".txt" pattern="combined" resolveHosts="false"/>
<Context path="" docBase="" reloadable="false" />
</Host>' > /var/robust/worker1/conf/server.host

cp -rf /var/robust/worker1/conf/server.host /var/robust/worker2/conf/server.host

echo ' </Engine>

</Service>

</Server>' > /var/robust/worker1/conf/server.footer

cp -rf /var/robust/worker1/conf/server.footer /var/robust/worker2/conf/server.footer



cd /var/robust/worker1/conf
cat server.header server.host server.footer > server.xml
cd /var/robust/worker2/conf
cat server.header server.host server.footer > server.xml

#
# generate tomcat-users.xml
#
MANAGER_PASSWORD=`head -1024c /dev/urandom | md5sum | cut -d " " -f1 | awk '{print substr($1,1,8)}'`
echo '<tomcat-users>
<user username="manager" password="'${MANAGER_PASSWORD}'" roles="manager"/>
</tomcat-users>' > /var/robust/worker1/conf/tomcat-users.xml
echo
echo "Your Tomcat Manager's login is 'manager', password is '${MANAGER_PASSWORD}'"
echo
cp -rf /var/robust/worker1/conf/tomcat-users.xml /var/robust/worker2/conf/tomcat-users.xml

chmod 600 /var/robust/worker*/conf/server.*
chmod 600 /var/robust/worker*/conf/tomcat-users.xml
chown -R tomcat:tomcat /var/apache-tomcat-*
chown -R tomcat:tomcat /var/robust

#
# generate mod_jk.conf
#
echo 'LoadModule jk_module modules/mod_jk.so

JkWorkersFile "/etc/httpd/conf/workers.properties"
JkLogFile "|/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 86400"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkRequestLogFormat "%w %V %T"
LogFormat "%h %l %u %t \"%r\" %>s %b %{JK_WORKER_NAME}n %{JK_LB_FIRST_NAME}n %{JK_LB_FIRST_BUSY}n %{JK_LB_LAST_NAME}n %{JK_LB_LAST_BUSY}n" mod_jk_log
CustomLog logs/worker_access_log mod_jk_log

JkMount /*.jsp loadbalancer
JkMount /*.do loadbalancer
JkMount /*.page loadbalancer
JkMount /dwr/* loadbalancer
JkMount /servlet/* loadbalancer
JkMount /manager/* loadbalancer

# Deny direct access to WEB-INF
<LocationMatch ".*WEB-INF.*">
deny from all
</LocationMatch>' > /etc/httpd/conf.d/mod_jk.conf
echo 'rm -rf /etc/httpd/conf.d/mod_jk.conf' >> ${SETUP_FILE_PATH}/cleanup.sh

#
# generate workers.properties
#
echo '# workers.properties - ajp13
#
# List workers
worker.list=worker1, worker2, loadbalancer, jkstatus

#
# Define worker1
#
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8109
worker.worker1.socket_timeout=1200
worker.worker1.connection_pool_size=1
worker.worker1.connection_pool_timeout=1300
worker.worker1.lbfactor=1
# Define prefered failover node for worker1
worker.worker1.redirect=worker2

#
# Define worker2
#
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8209
worker.worker2.socket_timeout=1200
worker.worker2.connection_pool_size=1
worker.worker2.connection_pool_timeout=1300
worker.worker2.lbfactor=1
# Disable worker2 for all requests except failover
worker.worker2.activation=false

#
# Defining a load balancer
#
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1, worker2

#
# Define status worker
#
worker.jkstatus.type=status' > /etc/httpd/conf/workers.properties
echo 'rm -rf /etc/httpd/conf/workers.properties' >> ${SETUP_FILE_PATH}/cleanup.sh

#
# generate tomcat startup script
#
echo '#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 86 14
# description: Tomcat Servlet Engine
# processname: tomcat
# pidfile: /var/run/worker1.pid /var/run/worker2.pid

# Source function library.
. /etc/rc.d/init.d/functions

# User under which tomcat will run
TOMCAT_USER=tomcat

RETVAL=0

CATALINA_HOME=/var/tomcat6
WORKER_ROOT="/var/robust"
WORKER_LIST=( worker1 worker2 )
WORKER_PORT=( 8105 8205 )

# start, debug, stop, and status functions
start() {
# Start Tomcat in normal mode
for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
do
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
if [ $SHUTDOWN_PORT -ne 0 ]; then
echo "Tomcat ${WORKER_LIST[i]} already started"
else
echo "Starting tomcat ${WORKER_LIST[i]}..."

CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}"
rm -rf $CATALINA_BASE/work/*

chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME
chown -R $TOMCAT_USER:$TOMCAT_USER $WORKER_ROOT
su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/startup.sh"
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
while [ $SHUTDOWN_PORT -eq 0 ]; do
sleep 1
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
done
echo "Tomcat ${WORKER_LIST[i]} started in normal mode"
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid
fi
done
}

debug() {
# Start Tomcat in debug mode
for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
do
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
if [ $SHUTDOWN_PORT -ne 0 ]; then
echo "Tomcat ${WORKER_LIST[i]} already started"
else
echo "Starting tomcat ${WORKER_LIST[i]} in debug mode..."

CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}"
rm -rf $CATALINA_BASE/work/*

chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME
chown -R $TOMCAT_USER:$TOMCAT_USER $WORKER_ROOT
su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/catalina.sh jpda start"
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
while [ $SHUTDOWN_PORT -eq 0 ]; do
sleep 1
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
done
echo "Tomcat ${WORKER_LIST[i]} started in debug mode"
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid
fi
done
}

stop() {
for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
do
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
if [ $SHUTDOWN_PORT -eq 0 ]; then
echo "Tomcat ${WORKER_LIST[i]} already stopped"
else
echo "Stopping tomcat ${WORKER_LIST[i]} ..."
CATALINA_BASE="$WORKER_ROOT/${WORKER_LIST[i]}"
su -l $TOMCAT_USER -c "export CATALINA_BASE=$CATALINA_BASE; $CATALINA_HOME/bin/shutdown.sh"
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
while [ $SHUTDOWN_PORT -ne 0 ]; do
sleep 1
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
done
RETVAL=$?
echo "Tomcat ${WORKER_LIST[i]} stopped"
[ $RETVAL=0 ] && rm -f /var/lock/subsys/${WORKER_LIST[i]} /var/run/${WORKER_LIST[i]}.pid
fi
done
}

status() {
for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
do
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep ${WORKER_PORT[i]}|wc -l`
if [ $SHUTDOWN_PORT -eq 0 ]; then
echo "Tomcat ${WORKER_LIST[i]} stopped"
else
MODE="normal"
JPDA_PORT=`netstat -vatn|grep LISTEN|grep 8000|wc -l`
if [ $JPDA_PORT -ne 0 ]; then
MODE="debug"
fi
echo "Tomcat ${WORKER_LIST[i]} running in $MODE mode"
fi
done
}

case "$1" in
start)
start
;;
debug)
debug
;;
stop)
stop
;;
restart)
stop
start
;;
redebug)
stop
debug
;;
status)
status
;;
*)
echo "Usage: $0 {start|debug|stop|restart|redebug|status}"
exit 1
esac

exit $RETVAL' > /etc/rc.d/init.d/tomcat

chmod 755 /etc/rc.d/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on

echo 'chkconfig tomcat off' >> ${SETUP_FILE_PATH}/cleanup.sh
echo 'chkconfig --del tomcat' >> ${SETUP_FILE_PATH}/cleanup.sh
echo 'rm -rf /etc/init.d/tomcat' >> ${SETUP_FILE_PATH}/cleanup.sh

chmod 755 ${SETUP_FILE_PATH}/cleanup.sh

echo 'Tomcat installation is completed!'
echo
echo 'You can type "service tomcat start" to start using tomcat now.'
echo 'Open a browser, and go to http://'${hostname}' to see it.'


2.啟動Tomcat
service tomcat start

3.重新啟動Apache
service httpd restart

參考資料:
Apache Virtual Host 最簡單的做法 (含 DNS,讓你建目錄等於建虛擬主機 )
How to Disable SELinux
Integrating Tomcat and Apache on Red Hat Linux
 檔案名稱 httpd_jdk-setup.sh [Disk] 下載
 描述 Apache and JDK Auto Installer
 檔案大小 872 bytes
 下載次數:  82 次

 檔案名稱 diff.txt [Disk] 下載
 描述 Apaceh httpd.conf diff.txt
 檔案大小 2 Kbytes
 下載次數:  100 次

 檔案名稱 tomcat-setup.sh [Disk] 下載
 描述 Tomcat 6 Auto Installer
 檔案大小 16 Kbytes
 下載次數:  119 次


分享經驗 累積智慧
[WWW]
 
討論區首頁 » Application Server
前往:   
行動版