博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos7下安装tomcat
阅读量:6883 次
发布时间:2019-06-27

本文共 9416 字,大约阅读时间需要 31 分钟。

安装tomcat前需要先安装JDK,本文JDK安装目录:/java/jdk1.8.0_141

安装前先关闭防火墙:

[root@model ~]# systemctl stop firewalld.service[root@model ~]# systemctl disable firewalld.service

步骤1:解压apache-tomcat-7.0.79.tar.gz到home目录

[root@model ~]# tar -zxvf apache-tomcat-7.0.79.tar.gz

步骤2:创建目录/tomcat并将解压后的文件apache-tomcat-7.0.79移动到该目录下

[root@model ~]# mkdir /tomcat[root@model ~]# mv ~/apache-tomcat-7.0.79 /tomcat

步骤3:配置tomcat的catalina.sh文件(文件中添加红色部分)

[root@model bin]# vi /tomcat/apache-tomcat-7.0.79/bin/catalina.sh#!/bin/sh# Licensed to the Apache Software Foundation (ASF) under one or more# contributor license agreements.  See the NOTICE file distributed with# this work for additional information regarding copyright ownership.# The ASF licenses this file to You under the Apache License, Version 2.0# (the "License"); you may not use this file except in compliance with# the License.  You may obtain a copy of the License at##     http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.# -----------------------------------------------------------------------------# Control Script for the CATALINA Server## Environment Variable Prerequisites##   Do not set the variables in this script. Instead put them into a script#   setenv.sh in CATALINA_BASE/bin to keep your customizations separate.##   CATALINA_HOME   May point at your Catalina "build" directory.##   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions#                   of a Catalina installation.  If not present, resolves to#                   the same directory that CATALINA_HOME points to.##   CATALINA_OUT    (Optional) Full path to a file where stdout and stderr#                   will be redirected.#                   Default is $CATALINA_BASE/logs/catalina.out##   CATALINA_OPTS   (Optional) Java runtime options used when the "start",#                   "run" or "debug" command is executed.#                   Include here and not in JAVA_OPTS all options, that should#                   only be used by Tomcat itself, not by the stop process,#                   the version command etc.#                   Examples are heap size, GC logging, JMX ports etc.##   CATALINA_TMPDIR (Optional) Directory path location of temporary directory#                   the JVM should use (java.io.tmpdir).  Defaults to#                   $CATALINA_BASE/temp.##   JAVA_HOME       Must point at your Java Development Kit installation.#                   Required to run the with the "debug" argument.##   JRE_HOME        Must point at your Java Runtime installation.#                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME#                   are both set, JRE_HOME is used.##   JAVA_OPTS       (Optional) Java runtime options used when any command#                   is executed.#                   Include here and not in CATALINA_OPTS all options, that#                   should be used by Tomcat and also by the stop process,#                   the version command etc.#                   Most options should go into CATALINA_OPTS.##   JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories#                   containing some jars in order to allow replacement of APIs#                   created outside of the JCP (i.e. DOM and SAX from W3C).#                   It can also be used to update the XML parser implementation.#                   Defaults to $CATALINA_HOME/endorsed.##   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"#                   command is executed. The default is "dt_socket".##   JPDA_ADDRESS    (Optional) Java runtime options used when the "jpda start"#                   command is executed. The default is 8000.##   JPDA_SUSPEND    (Optional) Java runtime options used when the "jpda start"#                   command is executed. Specifies whether JVM should suspend#                   execution immediately after startup. Default is "n".##   JPDA_OPTS       (Optional) Java runtime options used when the "jpda start"#                   command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,#                   and JPDA_SUSPEND are ignored. Thus, all required jpda#                   options MUST be specified. The default is:##                   -agentlib:jdwp=transport=$JPDA_TRANSPORT,#                       address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND##   JSSE_OPTS       (Optional) Java runtime options used to control the TLS#                   implementation when JSSE is used. Default is:#                   "-Djdk.tls.ephemeralDHKeySize=2048"##   CATALINA_PID    (Optional) Path of the file which should contains the pid#                   of the catalina startup java process, when start (fork) is#                   used##   LOGGING_CONFIG  (Optional) Override Tomcat's logging config file#                   Example (all one line)#                   LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"##   LOGGING_MANAGER (Optional) Override Tomcat's logging manager#                   Example (all one line)#                   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"##   USE_NOHUP       (Optional) If set to the string true the start command will#                   use nohup so that the Tomcat process will ignore any hangup#                   signals. Default is "false" unless running on HP-UX in which#                   case the default is "true"# -----------------------------------------------------------------------------# OS specific support.  $var _must_ be set to either true or false.JAVA_OPTS="-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m"export TOMCAT_HOME=/tomcat/apache-tomcat-7.0.79export CATALINA_HOME=/tomcat/apache-tomcat-7.0.79export JRE_HOME=/java/jdk1.8.0_141/jreexport JAVA_HOME=/java/jdk1.8.0_141cygwin=falsedarwin=falseos400=falsehpux=falsecase "`uname`" inCYGWIN*) cygwin=true;;Darwin*) darwin=true;;OS400*) os400=true;;HP-UX*) hpux=true;;esac# resolve links - $0 may be a softlinkPRG="$0"while [ -h "$PRG" ]; do  ls=`ls -ld "$PRG"`  link=`expr "$ls" : '.*-> \(.*\)$'`  if expr "$link" : '/.*' > /dev/null; then    PRG="$link"  else    PRG=`dirname "$PRG"`/"$link"  fidone

 步骤4:修改tomcat端口参数(红色部分)

[root@model conf]# vi /tomcat/apache-tomcat-7.0.79/conf/server.xml

 步骤4:启动和关闭tomcat

[root@model ~]# cd /tomcat/apache-tomcat-7.0.79/bin/[root@model bin]# [root@model bin]# [root@model bin]# [root@model bin]# lsbootstrap.jar       commons-daemon-native.tar.gz  digest.sh         startup.bat           tool-wrapper.shcatalina.bat        configtest.bat                setclasspath.bat  startup.sh            version.batcatalina.sh         configtest.sh                 setclasspath.sh   tomcat-juli.jar       version.shcatalina-tasks.xml  daemon.sh                     shutdown.bat      tomcat-native.tar.gzcommons-daemon.jar  digest.bat                    shutdown.sh       tool-wrapper.bat[root@model bin]# [root@model bin]# [root@model bin]# ./startup.sh #启动tomcatUsing CATALINA_BASE:   /tomcat/apache-tomcat-7.0.79Using CATALINA_HOME:   /tomcat/apache-tomcat-7.0.79Using CATALINA_TMPDIR: /tomcat/apache-tomcat-7.0.79/tempUsing JRE_HOME:        /java/jdk1.8.0_141/jreUsing CLASSPATH:       /tomcat/apache-tomcat-7.0.79/bin/bootstrap.jar:/tomcat/apache-tomcat-7.0.79/bin/tomcat-juli.jarTomcat started.[root@model bin]# [root@model bin]# [root@model bin]# [root@model bin]# ./shutdown.sh #关闭tomcatUsing CATALINA_BASE:   /tomcat/apache-tomcat-7.0.79Using CATALINA_HOME:   /tomcat/apache-tomcat-7.0.79Using CATALINA_TMPDIR: /tomcat/apache-tomcat-7.0.79/tempUsing JRE_HOME:        /java/jdk1.8.0_141/jreUsing CLASSPATH:       /tomcat/apache-tomcat-7.0.79/bin/bootstrap.jar:/tomcat/apache-tomcat-7.0.79/bin/tomcat-juli.jarJava HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=512m; support was removed in 8.0Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0[root@model bin]# [root@model bin]#

步骤5:查看tomcat运行日志

[root@model ~]# [root@model ~]# cd /tomcat/apache-tomcat-7.0.79/logs/[root@model logs]# [root@model logs]# [root@model logs]# lscatalina.2017-07-31.log      host-manager.2017-08-01.log          localhost_access_log.2017-08-01.txtcatalina.2017-08-01.log      localhost.2017-07-31.log             manager.2017-07-31.logcatalina.out                 localhost.2017-08-01.log             manager.2017-08-01.loghost-manager.2017-07-31.log  localhost_access_log.2017-07-31.txt[root@model logs]# [root@model logs]# [root@model logs]# tail -f catalina.out

至此,tomcat安装完毕~

转载于:https://www.cnblogs.com/simple-man/p/7264623.html

你可能感兴趣的文章
matlab绘制单摆相图,单摆运动―相图.ppt
查看>>
C语言程序报告4,《C语言程序设计》 验 报 告4.doc
查看>>
arduino c语言开发环境,arduino开发环境介绍
查看>>
怎么培养c语言编程思维,刚起步学习编程C语言,要具备怎样样的思维才能学得轻松?...
查看>>
c语言数组转置什么意思,什么是数组转置
查看>>
android 抽屉组件,Android组件之DrawerLayout实现抽屉菜单
查看>>
android5动画,【Android 动画】动画详解之属性动画(五)
查看>>
HTML1个像素宽的代码,CSS的父元素宽度竟然会给子元素增加1像素的宽度
查看>>
html worker 执行函数,Web Worker 详细介绍
查看>>
mcp背景中如何html图片,smtp 邮件正文镶入图片 HTML代码等全过程
查看>>
fdisk非交互自动对磁盘分区格式化
查看>>
疯狂ios讲义之美化iOS应用
查看>>
Exchange 2013 前端 MSExchangeFrontEndTransport 2030的解决
查看>>
累并快乐的2014年
查看>>
让WP7下复杂列表选项生动起来
查看>>
在vSphere中为不同服务器配置IPMI功能
查看>>
nagios一键安装脚本
查看>>
MDT 2013 Update 1 Preview 部署 Windows 10之MDT 2013安装配置
查看>>
监控利器Nagios之一:监控本地NFS和外部HTTP、MySQL服务
查看>>
BGP重分布metric详解
查看>>