一台centos7.2服务器安装两个tomcat应用服务

一台Centos服务器安装两个tomcat8服务

1. 安装部署jdk打开链接,详细安装步骤

http://bbs.hfteams.com/forum.php?mod=viewthread&tid=13&extra=

2. 服务列表


应用服务


版本


服务器


Jdk


8u151


Centos7.2

127.0.0.1


Tomcat1


8.0.47


Tomcat2


8.0.47

3. 安装部署tomcat1

[[email protected] ~]#  tar zxf apache-tomcat-8.0.47.tar.gz

[[email protected] ~]#  mv apache-tomcat-8.0.47 /usr/local/tomcat

[[email protected] ~]#  vim /etc/profile

添加tomcat1配置

#tomcat1

TOMCAT_HOME=/usr/local/tomcat

CATALINA_HOME=/usr/local/tomcat

CATALINA_BASE=/usr/local/tomcat

export  TOMCAT_HOME  CATALINA_HOME CATALINA_BASE

保存退出 (:wq)

执行/etc/profile文件  查看PATH变量是否生效

[[email protected] ~]# source /etc/profile

[[email protected] ~]# echo $PATH

/usr/local/tomcat/bin:/usr/local/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

查看tomcat版本及信息

[[email protected] ~]# catalina.sh version

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/local/java

Using CLASSPATH:       /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Server version: Apache Tomcat/8.0.47

Server built:   Sep 29 2017 13:46:41 UTC

Server number:  8.0.47.0

OS Name:        Linux

OS Version:     3.10.0-514.el7.x86_64

Architecture:   amd64

JVM Version:    1.8.0_151-b12

JVM Vendor:     Oracle Corporation

给tomcat/bin执行文件添加执行权限并启动tomcat1

[[email protected] ~]# chmod +x /usr/local/tomcat/bin/*.sh

[[email protected] ~]# /usr/local/tomcat/bin/startup.sh

Using CATALINA_BASE:   /usr/local/tomcat

Using CATALINA_HOME:   /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JRE_HOME:        /usr/local/java

Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

查看端口是否生效,是否有8080端口

添加防火墙规则允许8080端口通过

[[email protected] ~]# firewall-cmd --add-prot=8080/tcp

4. 部署tomcat2

安装步骤跟tomcat1一样,只需要改一下安装目录名,我改的是tomcat8

[[email protected] ~]# /usr/local/tomcat8/

给tomcat/bin执行文件添加执行权限

[[email protected] ~]# chmod +x /usr/local/tomcat/bin/*.sh

[[email protected] ~]#  vim /etc/profile

#tomcat2

TOMCAT_8_HOME=/usr/local/tomcat8

CATALINA_8_HOME=/usr/local/tomcat8

CATALINA_8_BASE=/usr/local/tomcat8

export  TOMCAT_8_HOME  CATALINA_8_HOME CATALINA_8_BASE

完整profile配置文件

# /etc/profile

pathmunge () {

case ":${PATH}:" in

*:"$1":*)

;;

*)

if [ "$2" = "after" ] ; then

PATH=$PATH:$1

else

PATH=$1:$PATH

fi

esac

}

if [ -x /usr/bin/id ]; then

if [ -z "$EUID" ]; then

# ksh workaround

EUID=`/usr/bin/id -u`

UID=`/usr/bin/id -ru`

fi

USER="`/usr/bin/id -un`"

LOGNAME=$USER

MAIL="/var/spool/mail/$USER"

fi

# Path manipulation

if [ "$EUID" = "0" ]; then

pathmunge /usr/sbin

pathmunge /usr/local/sbin

else

pathmunge /usr/local/sbin after

pathmunge /usr/sbin after

fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`

HISTSIZE=1000

if [ "$HISTCONTROL" = "ignorespace" ] ; then

export HISTCONTROL=ignoreboth

else

export HISTCONTROL=ignoredups

fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then

umask 002

else

umask 022

fi

for i in /etc/profile.d/*.sh ; do

if [ -r "$i" ]; then

if [ "${-#*i}" != "$-" ]; then

. "$i"

else

. "$i" >/dev/null

fi

fi

done

unset i

unset -f pathmunge

export JAVA_HOME=/usr/local/java

CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

PATH=$PATH:$JAVA_HOME/bin

JRE_HOME=$JAVA_HOME/jre

export JAVA_HOME

export PATH

export CLASSPATH

#export PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$PATH

#tomcat1

TOMCAT_HOME=/usr/local/tomcat

CATALINA_HOME=/usr/local/tomcat

CATALINA_BASE=/usr/local/tomcat

export  TOMCAT_HOME  CATALINA_HOME CATALINA_BASE

#tomcat2

TOMCAT_8_HOME=/usr/local/tomcat8

CATALINA_8_HOME=/usr/local/tomcat8

CATALINA_8_BASE=/usr/local/tomcat8

export  TOMCAT_8_HOME  CATALINA_8_HOME CATALINA_8_BASE

修改tomcat2端口conf/server.xml 红色字体都需要改

<?xml version='1.0' encoding='utf-8'?>

<Server port="9005" shutdown="SHUTDOWN">

<Listener className="org.apache.catalina.startup.VersionLoggerListener" />

<Listener className="org.apache.catalina.security.SecurityListener" />

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>

<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">

<Connector port="9080" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443" />

<Connector port="9009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="localhost">

<Realm className="org.apache.catalina.realm.LockOutRealm">

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"

resourceName="UserDatabase"/>

</Realm>

<Host name="localhost"  appBase="webapps"

unpackWARs="true" autoDeploy="true">

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

prefix="localhost_access_log" suffix=".txt"

pattern="%h %l %u %t "%r" %s %b" />

</Host>

</Engine>

</Service>

</Server>

修改bin/shutdown.sh 在exec "$PRGDIR"/"$EXECUTABLE" stop "[email protected]"添加红色字体

export JAVA_HOME=/usr/local/java

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=$JAVA_HOME/lib

export CATALINA_HOME=$CATALINA_8_HOME

export CATALINA_BASE=$CATALINA_8_BASE

exec "$PRGDIR"/"$EXECUTABLE" stop "[email protected]"

修改bin/startup.sh 在exec "$PRGDIR"/"$EXECUTABLE" stop "[email protected]"添加红色字体

export JAVA_HOME=/usr/local/java

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=$JAVA_HOME/lib

export CATALINA_HOME=$CATALINA_8_HOME

export CATALINA_BASE=$CATALINA_8_BASE

启动tomcat2

[[email protected] ~]# vim /usr/local/tomcat8/bin/startup.sh

原文地址:http://blog.51cto.com/12832314/2059369

时间: 2024-10-18 04:33:46

一台centos7.2服务器安装两个tomcat应用服务的相关文章

一台Linux上搭建两个tomcat

如题,本次博文的内容是在一台Linux上搭建2个tomcat,很蛋疼的需求,但必须得做 1,复制原tomcat并重命名tomcat cp /usr/local/tomcat /usr/local/tomcat2 修改外部环境 vim /etc/profile export JAVA_HOME=/usr/java/jdk1.8.0_73 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_H

如何在一台机子上启动两个TOMCAT

同时启动两个tomcat设置,具体如下: 1.不要设置CATALINA_HOME 2.分别修改安装目录下的conf子目录中的server.xml文件: a.修改http访问端口为不同的端口,将8080修改为tomcat不在使用的端口号.此处所设的端口号即是以后访问web时所用的端口号. b.修改其中一个tomcat的Shutdown端口(在server.xml中,默认为8005端口),将8005修改为没有在使用的端口号,例如8055. c.修改其中一个tomcat的8009端口,将8009修改为

同一台电脑上安装两个tomcat服务器

1.下载免安装版tomcat,解压成tomcat1.tomcat2: 2.修改tomcat2中conf下server.xml文件如下: <Server port="8005" shutdown="SHUTDOWN">将port中8005修改成8006(或者其他未使用端口): <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150

同一个服务器安装两个tomcat

1.在/etc/profile中    export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL    export JAVA_HOME=/usr/java/jdk1.7.0_71    export JRE_HOME=$JAVA_HOME/jre    export PATH=$JAVA_HOME/bin:$PATH    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib

在一台电脑上运行两个或多个tomcat

在一台电脑上运行多个tomcat 在本例中,使用两个tomcat做示例 工具/原料 tomcat 安装好jdk,并且配置好环境变量 方法/步骤 首先去apache下载一个tomcat,下载解压版的,比较方便 把这个tomcat,解压两次,为了方便显示,我把解压出来的tomcat重命名成tomcat11111和tomcat22222 修改其中一个tomcat中的某些参数,为了避免启动tomcat时出现冲突,编辑bin/startup.bat, 在文件第一行添加如下两行 SET JAVA_HOME=

一台电脑上同启动两个Tomcat的方式

?? 安装两个jdk,一个JDK路径在:C:\ProgramFiles (x86)\Java\jdk1.7.0_25,另外一个JDK的路径在E:\UCMSServer\j2sdk 在环境变量里并设置JAVA_HOME为:E:\UCMSServer\j2sdk 复制两个Tomcat,分别命名成:tomcat-61111和 tomcat-62222,如下所示: 进入tomcat-61111\bin,修改startup.bat,在该文件的最上面添加如下两行代码: SET JAVA_HOME=C:\Pr

同一台机子 打开两个tomcat

因为项目测试需要,需要在机子上单独搭建一个图片服务器,所以就要同时打开两个tomcat,这里记录方法. 1.首先复制一个新的tomcat程序: 2.在新的tomcat程序中修改server.xml的三个端口号: 一.<Server port="8005" shutdown="SHUTDOWN">,修改为8050 二. <Connector port="8080" protocol="HTTP/1.1",修为为

同一台电脑运行两个tomcat

主要就是修改配置文件使两个tomcat的端口不冲突 修改tomcat2中conf下server.xml文件如下: <Server port="8005" shutdown="SHUTDOWN">将port中8005修改成8006(或者其他未使用端口): <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minS

解决一台机器同时运行多个Tomcat服务

http://www.cnblogs.com/itolssy/archive/2008/09/09/1278041.html 如果不加任何修改,在一台服务器上同时运行两个Tomcat服务显然会发生端口冲突.假设现在已经按照正常的方式安装配置好了第一个Tomcat,第二个如何设置呢?以下是使用Tomcat6.0.16解压版本所做的实验. 解决办法: 1.解压Tomcat到一个新的目录,比如d:\TomcatServer2; 2.新建一个环境变量CATALINA_HOME2,路径为d:\Tomcat