一. 环境
1.操作系统: Suse Linux 10
2.jdk: 1.6.0_13 (使用RPM包安装)
3.jdk安装目录: /usr/java/default => /usr/java/jdk1.6.0_13
4.tomcat: tomcat6.0.20 (官方下载tgz包,直接解压到/usr/local/tomcat)
5.tomcat安装目录: /usr/local/tomcat
(一直漂[鱼漂]原创,转载请注册)

二.创建用户
#useradd -u 1003 -g users webadmin

三.修改目录所有者
#chown -R webadmin.users /usr/local/tomcat

四.安装jsvc
#cd /usr/local/tomcat/bin
#tar xvfz jsvc.tar.gz
#mv jsvc-src jsvc
#cd jsvc
#sh ./support/buildconf.sh
#chmod 755 configure
#./configure --with-java=/usr/java/default
#make
注意查看当前目录,是否生成了jsvc可执行文件.

五.修改启动文件
#vi ./native/Tomcat5.sh
改成如下内容:
(主要修改了前面的配置部分,以及start,stop中的jsvc的路径)

#!/bin/sh
##############################################################################
#
#   Copyright 2004 The Apache Software Foundation.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
#    <Connector className="org.apache.catalina.connector.http.HttpConnector"
#               port="80" minProcessors="5" maxProcessors="75"
#               enableLookups="true" redirectPort="8443"
#               acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java/default
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=/usr/local/tomcat/bin/jsvc
TOMCAT_USER=webadmin
JAVA_OPTS="-Xms512m -Xmx1024m -XX:PermSize=64M"

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/tomcat

CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
  start)
    #
    # Start Tomcat
    #
    $DAEMON_HOME/jsvc \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $CATALINA_HOME/logs/catalina.out \
    -errfile '&1' \
    $JAVA_OPTS \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;

  stop)
    #
    # Stop Tomcat
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac
                                              


六.拷贝启动文件
#cp ./native/Tomcat5.sh /etc/init.d/tomcat6
#chmod a+x /etc/init.d/tomcat6

七.添加服务
#chkconfig --add tomcat6
#chkconfig --level 345 tomcat6 on

八.完成,启动服务
#/etc/init.d/tomcat6 start | stop
同时重启系统,tomcat也就会自动启动了.

九.中文文件名问题
Linux下的Tomcat在下载中文文件名时,有时会出现无法下载,404错误的页面,可以通过下面的方法修复此问题:
1. 修改server.xml,在connector中加入URIEncoding="UTF-8",告诉Tomcat使用UTF-8来解析URL(IE默认是用utf-8编码URL)
2. 修改tomcat启动脚本,加上export LC_ALL="zh_CN.gbk",使得Tomcat在读定系统系统时,使用gbk编码处理文件名。(也可以设置为其它编码,如UTF8)

分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]