linux系统里面安装tomcat+运行war包

环境



  • 系统:centos 7
  • jdk1.8(安装教程)

注意:安装tomacat,环境变量的配置,主要就是jdk的配置,jdk的环境变量配置成功,tomcat就配置成功。

下载安装


下载安装tomcat,去官网下载安装格式为.tar.gz的安装包,版本号按照自己需求进行选择。
本文安装的版本是apache-tomcat-7.0.81

[root@localhost ~]# cd /usr/local/lib
[root@localhost lib]#  wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.81/bin/apache-tomcat-7.0.81.tar.gz

安装到/usr/lib/tomcat

[root@localhost lib]#cd /usr/lib/
[root@localhost lib]#mkdir tomcat
[root@localhost lib]#cd /usr/local/lib
[root@localhost lib]#tar -zxvf apache-tomcat-7.0.81.tar.gz  -C /usr/lib/tomcat

运行


进入tomcat目录,运行tomcat。

[root@localhost lib]#cd /usr/lib/tomcat
[root@localhost lib]#./bin/start.sh
Using CATALINA_BASE:   /usr/lib/tomcat/apache-tomcat-7.0.81
Using CATALINA_HOME:   /usr/lib/tomcat/apache-tomcat-7.0.81
Using CATALINA_TMPDIR: /usr/lib/tomcat/apache-tomcat-7.0.81/temp
Using JRE_HOME:        /usr/lib/jvm/jdk1.8.0_161/jre
Using CLASSPATH:       /usr/lib/tomcat/apache-tomcat-7.0.81/bin/bootstrap.jar:/usr/lib/tomcat/apache-tomcat-7.0.81/bin/tomcat-juli.jar
Tomcat started.

Tomcat安装完成,用浏览器访问http://localhost:8080/,显示Tomcat默认页面,说明已经安装成功。
如果要停止Tomcat,运行shutdown.sh停止Tomcat。命令行:

[root@localhost lib]#./bin/shutdown.sh

或者使用kill -9命令来查杀进程

[root@localhost apache-tomcat-7.0.81]# ps -ef|grep tomcat
root     15052     1 36 10:31 pts/0    00:23:28 /usr/lib/jvm/jdk1.8.0_161/jre/bin/java -Djava.util.logging.config.file=/usr/lib/tomcat/apache-tomcat-7.0.81/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/usr/lib/tomcat/apache-tomcat-7.0.81/endorsed -classpath /usr/lib/tomcat/apache-tomcat-7.0.81/bin/bootstrap.jar:/usr/lib/tomcat/apache-tomcat-7.0.81/bin/tomcat-juli.jar -Dcatalina.base=/usr/lib/tomcat/apache-tomcat-7.0.81 -Dcatalina.home=/usr/lib/tomcat/apache-tomcat-7.0.81 -Djava.io.tmpdir=/usr/lib/tomcat/apache-tomcat-7.0.81/temp org.apache.catalina.startup.Bootstrap start
root     15847 14057  0 11:35 pts/0    00:00:00 grep --color=auto tomcat
[root@localhost apache-tomcat-7.0.81]# kill -9 15052
[root@localhost apache-tomcat-7.0.81]# ps -ef|grep tomcat
root     15849 14057  0 11:36 pts/0    00:00:00 grep --color=auto tomcat
[root@localhost apache-tomcat-7.0.81]# 

运行war包


首先,你要有一个war包,自己项目的war包打包这里就不讲了。

  • 1.将war包放入tomcat的webapps下
    linux系统里面安装tomcat+运行war包_第1张图片
  • 2.修改tomcat目录conf下的server.xml,docBase即导入的WAR包的名
    linux系统里面安装tomcat+运行war包_第2张图片
  • 3.启动Tomcat,访问项目
[root@localhost lib]#./bin/start.sh
Using CATALINA_BASE:   /usr/lib/tomcat/apache-tomcat-7.0.81
Using CATALINA_HOME:   /usr/lib/tomcat/apache-tomcat-7.0.81
Using CATALINA_TMPDIR: /usr/lib/tomcat/apache-tomcat-7.0.81/temp
Using JRE_HOME:        /usr/lib/jvm/jdk1.8.0_161/jre
Using CLASSPATH:       /usr/lib/tomcat/apache-tomcat-7.0.81/bin/bootstrap.jar:/usr/lib/tomcat/apache-tomcat-7.0.81/bin/tomcat-juli.jar
Tomcat started.
  • 4.最后就是浏览器输入网址进行访问就可以了

你可能感兴趣的:(tomcat)