1. 找到tomcat安装包 find / -name apache-tomcat*
2. 解压包 tar zxvf apache-tomcat-7.0.67.tar.gz
rpm -ivh jdk***.rpm
3. mv apache-tomcat-7.0.67 /usr/local/tomcat2
mv jdk* /usr/local/
配置
添加环境变量
vi /etc/profile
在文件最后添加如下内容:
JAVA_HOME=/usr/local/jdk1.7.0_79PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport PATHexport CLASSPATH#第一个TomcatCATALINA_BASE=/usr/local/tomcatCATALINA_HOME=/usr/local/tomcatexport CATALINA_BASE CATALINA_HOME#第二个TomcatCATALINA_2_BASE=/usr/local/tomcat2CATALINA_2_HOME=/usr/local/tomcat2export CATALINA_2_BASE CATALINA_2_HOME#第一个Tomcat路径TOMCAT_HOME=/usr/local/tomcatexport TOMCAT_HOME#第二个Tomcat路径TOMCAT_2_HOME=/usr/local/tomcat2export TOMCAT_2_HOME
保存退出 执行 source /etc/profile 使文件生效。
在第2个tomcat的bin目录下,在catalina.sh中加入
JAVA_OPTS="-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m"export CATALINA_BASE=$CATALINA_2_BASEexport CATALINA_HOME=$CATALINA_2_HOME
可选
JAVA_HOME=/usr/local/jdk1.7.0_79 PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export CATALINA_BASE=/usr/local/tomcat export CATALINA_HOME=/usr/local/tomcat
更改端口:
第一个tomcat,保持解压后的原状不用修改,
第二个tomcat,修改server.xml配置和第一个不同的启动、关闭监听端口。
修改后示例如下:
<Server port="9005" shutdown="SHUTDOWN"> 端口:8005->9005
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector port="9080" maxHttpHeaderSize="8192" 端口:8080->9080
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="9009" 端口:8009->9009
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
关闭防火墙
chkconfig iptables off
service iptables stop
启动tomcat
将项目business拷贝至/usr/local/tomcat/webapps下
编辑server.xml文件,添加
<Context path="" docBase="/usr/local/tomcat/webapps/business" reloadable="true"/>
保存退出。
启动:/usr/local/tomcat/bin/startup.sh
关闭:/usr/local/tomcat/bin/shutdown.sh
之后发现启动不了服务器的问题, 发现PAS_V1这个war没有自动解包
用命令 jar -xvf **.jar
启动服务器就去各自的服务器里startup.sh就可以了
我的服务器设置:
tomcat1: cd /usr/local/tomcat/bin1. rm -rf /usr/local/tomcat/webapps/PA*2. rm -rf /usr/local/tomcat/work/Catalina/localhost3. cp /home/PAS/war/*.war /usr/local/tomcat/webapps/4. cd /usr/local/tomcat/webapps/ mkdir PAS_V1 jar -xvf PA*.war5. startup.shtomcat2:1. rm -rf /usr/local/tomcat2/webapps/po* rm -rf /usr/local/tomcat2/webapps/PA*2. rm -rf /usr/local/tomcat2/work/Catalina/localhost3. cp /home/PAS/war/*.war /usr/local/tomcat2/webapps/4. cd /usr/local/tomcat2/webapps/ mkdir portal mkdir PAS_V2 cp portal.war ./portal cp PAS_V2.war ./PAS_v2 jar -xvf *.war5. startup.sh查看启动信息:tail -f /usr/local/tomcat2/logs/catalina.outvi /usr/local/tomcat/logs/catalina.2016-08-31.log vi /usr/local/tomcat/logs/error-debug.2016-08-31.log两个samba服务器数据传输:smbclient //109.110.100.56/pas -U pasget ***exit一个tomcat的时候启动命令/etc/init.d/tomcat stop/etc/init.d/tomcat start