tomcat安装

安装tomcat

安装如下:

[root@localhost ~]# iptables -F
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
[root@localhost ~]# rpm -qa |grep -i opten jdk
grep: jdk: 没有那个文件或目录
[root@localhost ~]# rpm -qa |grep -i optenjdk
[root@localhost ~]# rpm -qa |grep -i openjdk
java-1.7.0-openjdk-1.7.0.141-2.6.10.5.el7.x86_64
java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.5.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64
[root@localhost ~]# rpm -e java-1.7.0-openjdk
[root@localhost ~]# rpm -e java-1.7.0-openjdk-headless
[root@localhost ~]# rpm -e java-1.8.0-openjdk
错误:依赖检测失败:
 java >= 1.5 被 (已安裝) jline-1.0-8.el7.noarch 需要
 java-1.8.0-openjdk 被 (已安裝) icedtea-web-1.6.2-4.el7.x86_64 需要
[root@localhost ~]# rpm -e java-1.8.0-openjdk --nodeps //忽略依赖关系
[root@localhost ~]# rpm -e java-1.8.0-openjdk-headless
[root@localhost ~]# rpm -qa |grep -i openjdk
(方法二:卸载Java
[root@localhost html]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
[root@localhost html]# which java
/usr/bin/java
[root@localhost html]# rm -rf /usr/bin/java
[root@localhost html]# java -version
-bash: /usr/bin/java: 没有那个文件或目录

安装软件包jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# tar xf jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg             original-ks.cfg  图片  桌面
initial-setup-ks.cfg        公共             文档
jdk1.8.0_191                模板             下载
jdk-8u191-linux-x64.tar.gz  视频             音乐
[root@localhost ~]# mv jdk1.8.0_191/ /usr/local/java //移动到指定路径
[root@localhost ~]# java -version   //使用这个查不出来
-bash: /usr/bin/java: 没有那个文件或目录
[root@localhost ~]# /usr/local/java/bin/java -version   //这个可以
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
[root@localhost ~]# vim /etc/profile   //编辑文件,在末行添加以下内容
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
···············
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# source /etc/profile
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/java/bin
[root@localhost ~]# java  -version  //这样就可以用这一条命令了
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
上传软件包apache-tomcat-8.5.40.tar.gz
[root@localhost ~]# rz -E
rz waiting to receive.
[root@localhost ~]# ls
anaconda-ks.cfg              original-ks.cfg  图片  桌面
apache-tomcat-8.5.40.tar.gz  公共             文档
initial-setup-ks.cfg         模板             下载
jdk-8u191-linux-x64.tar.gz   视频             音乐
·~~~~~~~~~
[root@localhost ~]# tar xf apache-tomcat-8.5.40.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg              original-ks.cfg  文档
apache-tomcat-8.5.40         公共             下载
apache-tomcat-8.5.40.tar.gz  模板             音乐
initial-setup-ks.cfg         视频             桌面
jdk-8u191-linux-x64.tar.gz   图片
[root@localhost ~]# mv apache-tomcat-8.5.40 /usr/local/tomcat8
[root@localhost ~]# ls /usr/local/tomcat8
bin              lib      README.md      webapps
BUILDING.txt     LICENSE  RELEASE-NOTES  work
conf             logs     RUNNING.txt
CONTRIBUTING.md  NOTICE   temp
[root@localhost ~]# ls /usr/local/tomcat8/bin/
bootstrap.jar                 setclasspath.sh
catalina.bat                  shutdown.bat
catalina.sh                   shutdown.sh
catalina-tasks.xml            startup.bat
commons-daemon.jar            startup.sh
commons-daemon-native.tar.gz  tomcat-juli.jar
configtest.bat                tomcat-native.tar.gz
configtest.sh                 tool-wrapper.bat
daemon.sh                     tool-wrapper.sh
digest.bat                    version.bat
digest.sh                     version.sh
setclasspath.bat
启动:
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat8
Using CATALINA_HOME:   /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Tomcat started.
[root@localhost ~]# netstat -lnpt | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      39318/java
在浏览器中进行访问
192.168.200.67:8080
关闭tomcat
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh

posted @ 2019-11-22 14:44  elin菻  阅读(158)  评论(0编辑  收藏  举报