Tomcat部署

        服务器配置

  • 10.8.8.100
  • 10.8.8.101
  • 10.8.8.102
  • 10.8.8.103
  • 10.8.8.104
  • 10.8.8.105
  • 10.8.8.106

所有服务器同时安装

一、安装JDK

        首先下载JDK,官方下载地址

        下载后解压

1
2
tar zxvf jdk-8u111-linux-x64.tar.gz
mv jdk1.8,0_111/ /usr/local/

        编译文件

1
vim /etc/profile.d/java.sh

        加入配置

1
2
3
4
5
6
JAVA_HOME=/usr/local/jdk1.8.0_111/
JAVA_BIN=/usr/local/jdk1.8.0_111/bin
JRE_HOME=/usr/local/jdk1.8.0_111/jre
PATH=$PATH:/usr/local/jdk1.8.0_111/bin:/usr/local/jdk1.8.0_111/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_111/jre/lib:/usr/local/jdk1.8.0_111/lib:/usr/local/jdk1.8.0_111/jre/lib/charsets.jar
export JAVA_HOME JAVA_BIN JRE_HOME PATH CLASSPATH

        然后初始化环境变量

1
source /etc/profile.d/java/sh

        如果配置成功,就可以看到java的版本

1
2
3
4
java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

二、tomcat安装

        Tomcat官网

        下载

1
2
cd /usr/local/src
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M19/bin/apache-tomcat-9.0.0.M19.tar.gz

        解压

1
2
3
4
[root@192 src]# tar zxf apache-tomcat-9.0.0.M19.tar.gz
[root@192 src]# mv apache-tomcat-9.0.0.M19 /usr/local/tomcat
[root@192 src]# cp -pv /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
"/usr/local/tomcat/bin/catalina.sh" -> "/etc/init.d/tomcat"

        编辑配置文件

1
[root@192 src]# vim /etc/init.d/tomcat

        从第二行加入配置

1
2
3
4
5
6
#chkconfig: 2345 63 37
#description: tomcat server init script
#Source Function Library
./etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_111
CATALINA_HOME=/usr/local/tomcat

01

        保存该文件,然后把tomcat加入服务列表里

1
2
3
4
5
6
7
8
9
10
11
[root@192 src]# chmod 755 /etc/init.d/tomcat
[root@192 src]# chkconfig --add tomcat
[root@192 src]# chkconfig tomcat on
[root@192 src]# service tomcat start
/etc/init.d/tomcat: line 5: ./etc/init.d/functions: Permission denied
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/local/jdk1.8.0_111
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

        在浏览器上输入IP:8080,就可以看到tomcat的欢迎页

02