首页 > 代码库 > tomcat安装

tomcat安装

1. 安装环境... 4

2. 安装步骤... 5

2.1. 安装JDK.. 5

2.2. 安装tomcat 5

3. 安装标准... 6

3.1. 程序安装目录... 6

3.2. 日志路径: 6

3.3. 启动脚本... 6

3.4. 配置文件... 7

3.5. 虚拟主机配置... 8

3.6. 重启脚本... 8

 

1.安装环境

OS: Linux

Tomcat: 6.0.24

JDK: sun jdk 1.6.0_27

 

2.安装步骤

2.1.安装JDK

参见

http://wiki.tomshopping.com/pages/viewpage.action?pageId=14288188

 

2.2.安装tomcat

# cd /data/postmall/steve

# wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.24/bin/apache-tomcat-6.0.24.tar.gz

# tar zxvf apache-tomcat-6.0.24.tar.gz

# cd /usr/local

# cp -r /data/postmall/steve/apache-tomcat-6.0.24 tomcat1

# cp -r /data/postmall/steve/apache-tomcat-6.0.24 tomcat2

# cp -r /data/postmall/steve/apache-tomcat-6.0.24 tomcat3

# chown -R web.users /usr/local/tomcat*

# chown -R web.users /data/logs/tomcat

# chown -R web.users /data/postmall/tomcat

 

3.安装标准

邮乐平台由于模块很多,需要很多容器来部署,为简化部署流程,节约硬件资源,缺省每台服务器最多安装3个tomcat, 即TOMCAT1, TOMCAT2, TOMCAT3, 便于区分辨认。

 

3.1.程序安装目录

TOMCAT1: /usr/local/tomcat1

TOMCAT2: /usr/local/tomcat2

TOMCAT3: /usr/local/tomcat3

 

3.2.日志路径:

TOMCAT1: /data/logs/tomcat/catalina8080.out.%Y%m%d (尾数是年月日)

TOMCAT2: /data/logs/tomcat/catalina9090.out.%Y%m%d (尾数是年月日)

TOMCAT3: /data/logs/tomcat/catalina7070.out.%Y%m%d (尾数是年月日)

 

3.3. 启动脚本

需要对 /usr/local/tomcat1/bin/catalina.sh 做如下修改:

增加以下部分

export LANG="en_US.UTF-8"

export LC_ALL="en_US.UTF-8"

export LC_CTYPE="en_US.UTF-8"

export JAVA_HOME=/usr/local/jdk

 

修改 JAVA_OPTS

JAVA_OPTS="$JAVA_OPTS -server -Xss128k -Xmx1536m -Xms512m -XX:MaxNewSize=256m -XX:MaxPermSize=512m -Dsun.lang.ClassLoader.allowArraySyntax=true "

 

修改日志输出
TOMCAT1:

2>&1 |/usr/sbin/rotatelogs /data/logs/tomcat/catalina8080.out.%Y%m%d 86400 480 &

# >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & (此行注释)

TOMCAT2:

2>&1 |/usr/sbin/rotatelogs /data/logs/tomcat/catalina9090.out.%Y%m%d 86400 480 &

# >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & (此行注释)

TOMCAT3:

2>&1 |/usr/sbin/rotatelogs /data/logs/tomcat/catalina7070.out.%Y%m%d 86400 480 &

# >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & (此行注释)

 

确保/usr/sbin/rotatelogs文件存在。(debian是/usr/sbin/rotatelogs, suse是/usr/sbin/rotatelogs2),没有的话需要安装相应模块。

 

3.4. 配置文件

TOMCAT1: /usr/local/tomcat1/conf/server.xml

Server port="8005"

Connector port="8080"

<Connector port="8009" maxHttpHeaderSize="8192" maxThreads="8192" minSpareThreads="256" maxSpareThreads="1024" acceptCount="2048" connectionTimeout="20000" enableLookups="false" compression="on" compressableMimeType="text/html,text/xml,text/plain,text/javascript,text/css" redirectPort="8443" protocol="AJP/1.3" URIEncoding="UTF-8" packetSize="65536" />

 

TOMCAT2: /usr/local/tomcat1/conf/server.xml

Server port="9005"

Connector port="9090"

<Connector port="9009" maxHttpHeaderSize="8192" maxThreads="8192" minSpareThreads="256" maxSpareThreads="1024" acceptCount="2048" connectionTimeout="20000" enableLookups="false" compression="on" compressableMimeType="text/html,text/xml,text/plain,text/javascript,text/css" redirectPort="9443" protocol="AJP/1.3" URIEncoding="UTF-8" packetSize="65536" />

 

TOMCAT3: /usr/local/tomcat1/conf/server.xml

Server port="7005"

Connector port="7070"

<Connector port="7009" maxHttpHeaderSize="8192" maxThreads="8192" minSpareThreads="256" maxSpareThreads="1024" acceptCount="2048" connectionTimeout="20000" enableLookups="false" compression="on" compressableMimeType="text/html,text/xml,text/plain,text/javascript,text/css" redirectPort="7443" protocol="AJP/1.3" URIEncoding="UTF-8" packetSize="65536" />

 

3.5.虚拟主机配置

<Host name="search.ulecn.tom.com" appBase="/data/postmall/tomcat/webapps_sphinxPostSearch" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

</Host>

 

3.6.重启脚本

TOMCAT1: ~/t1_restart.sh

TOMCAT2: ~/t2_restart.sh

TOMCAT3: ~/t3_restart.sh

本文出自 “zhanghe” 博客,请务必保留此出处http://9206668.blog.51cto.com/9196668/1535921