Tomcat部署实战!

a 夏天 提交于 2019-11-25 20:39:40

Tomcat部署及优化

1.Tomcat安装部署

2.虚拟主机配置

3.Tomcat优化

Tomcat介绍

1.免费的、开放源代码的Web应用服务器
2.Apache软件基金会(Apache Software Foundation)Jakarta项目中的- -个核心项目
3.由Apache、 Sun和一些公司及个人共同开发而成
4.深受Java爱好者的喜爱,并得到部分软件开发商的认可
5.目前比较流行的Web应用服务器

Tomcat部署步骤

1.下载并安装jdk

2.安装并启动Tomcat

3.配置虚拟主机

设置环境变量

1.编辑/etc/profile文件:

export JAVA_HOME=/usr/java/jdk1.8.0_171-amd64

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

export PATH=$JAVA_HOME/bin:$PATH

2.使环境变量生效的命令:

[root@localhost~]#source /etc/profile

3.查看jdk版本的命令:

[root@localhost~]#java -version

安装、启动Tomcat

1.下载安装包:

[root@localhost ~]# wget http://mirrors. shu.edu.cn/apache/tomcat/tomcat-9/v9.0.8/bin/apache-tomcat-9.0.8.tar.gz

2.将安装包移动到/usr/local下重命名:

[root@localhost ~]# mv apache-tomcat-9.0.8 /usr/ocal/tomcat

3.启动Tomcat:

[root@localhost ~]# /usr/local/tomcat/bin/startup.sh

Tomcat启动时间

1.缩短启动时间的命令
/usr/java/jdk1.8.0_171-amd64/je/lib/security/java.security文件

securerandom.source=file:/dev/random改为urandom

Demo:Tomcat安装

[root@localhost ~]# mkdir /aaa
[root@localhost ~]# mount.cifs //192.168.10.139/rpm /aaa
Password for root@//192.168.10.139/rpm:  
[root@localhost ~]# cd /aaa
[root@localhost aaa]# ls
amoeba-mysql-binary-2.2.0.tar.gz  lf.jpg
apr-1.6.2.tar.gz                  mysql-5.5.24.tar.gz
apr-util-1.6.0.tar.gz             mysql-5.6.26.tar.gz
httpd-2.4.29.tar.bz2              TC
[root@localhost aaa]# cd TC/
[root@localhost TC]# ls
apache-jmeter-5.1
apache-jmeter-5.1.zip
apache-tomcat-9.0.16.tar.gz
jdk-8u201-linux-x64.rpm
[root@localhost TC]# rpm -ivh jdk-8u201-linux-x64.rpm 
[root@localhost TC]# cd /usr/java/
[root@localhost java]# ls
default  jdk1.8.0_201-amd64  latest
[root@localhost java]# cd jdk1.8.0_201-amd64/
[root@localhost jdk1.8.0_201-amd64]# ls
bin             man
COPYRIGHT       README.html
include         release
javafx-src.zip  src.zip
jre             THIRDPARTYLICENSEREADME-JAVAFX.txt
lib             THIRDPARTYLICENSEREADME.txt
LICENSE

//设置环境变量:
[root@localhost jdk1.8.0_201-amd64]# vim /etc/profile
按大写字母G到末行,按小写字母o在下行插入以下内容:
export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$PATH
//修改完成后,按Esc退出插入模式,输入:wq保存退出
[root@localhost jdk1.8.0_201-amd64]# source /etc/profile
[root@localhost jdk1.8.0_201-amd64]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
[root@localhost jdk1.8.0_201-amd64]# cd /aaa
[root@localhost aaa]# ls
Discuz_X3.4_SC_UTF8.zip           nginx-1.12.2.tar.gz
error.png                         php-7.1.10.tar.bz2
extundelete-0.2.4.tar.bz2         php-7.1.20.tar.gz
httpd-2.4.29.tar.bz2              TC
[root@localhost aaa]# cd TC/
[root@localhost TC]# ls
apache-jmeter-5.1
apache-jmeter-5.1.zip
apache-tomcat-9.0.16.tar.gz
jdk-8u201-linux-x64.rpm
[root@localhost TC]# tar zxvf apache-tomcat-9.0.16.tar.gz -C /usr/local/
[root@localhost TC]# cd /usr/local/
[root@localhost local]# ls
apache-tomcat-9.0.16  etc    include  lib64    sbin   src
bin                   games  lib      libexec  share
//为方便后面查找,修改文件夹名
[root@localhost local]# mv apache-tomcat-9.0.16/ tomcat
[root@localhost local]# ls
bin  games    lib    libexec  share  tomcat
etc  include  lib64  sbin     src
[root@localhost local]# cd tomcat/
[root@localhost tomcat]# cd bin/
[root@localhost bin]# ls
bootstrap.jar                 makebase.sh
catalina.bat                  setclasspath.bat
catalina.sh                   setclasspath.sh
catalina-tasks.xml            shutdown.bat
ciphers.bat                   shutdown.sh
ciphers.sh                    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
makebase.bat
[root@localhost bin]# ln -s /usr/local/tomcat/bin/startup.sh /usr/bin/
[root@localhost bin]# ln -s /usr/local/tomcat/bin/shutdown.sh /usr/bin/
[root@localhost bin]# systemctl stop firewalld.service 
[root@localhost bin]# setenforce 0
[root@localhost 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/java/jdk1.8.0_201-amd64
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

此时使用宿主机浏览器输入地址:192.168.18.145:8080,可访问到Tomcat的主页:

在这里插入图片描述

此时Tmocat部署成功,谢谢观看!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!