CentOS-7.0中安装与配置Tomcat-8的方法
CentOS-7.0中安装与配置Tomcat-8的方法
투판시 发表于8个月前
CentOS-7.0中安装与配置Tomcat-8的方法
  • 发表于 8个月前
  • 阅读 21
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

安装说明 
安装环境:CentOS-7.0.1406
安装方式:源码安装 
软件:apache-tomcat-8.5.13.tar.gz
下载地址:http://tomcat.apache.org/download-80.cgi

 

安装前提 

在系统中,我安装的JDK版本是1.8

安装tomcat 


创建tomcat目录

mkdir  /usr/local/tomcat

将apache-tomcat-8.5.13.tar.gz文件上传到/usr/local/tomcat中执行以下操作:

[root@janus /]# cd /usr/local/tomcat 
[root@janus tomcat]# tar -zxv -f apache-tomcat-8.5.13.tar.gz // 解压压缩包  
[root@janus tomcat]# rm -rf apache-tomcat-8.5.13.tar.gz // 删除压缩包 

启动Tomcat

执行以下操作:

[root@janus /]# /usr/local/tomcat/apache-tomcat-8.5.13/bin/startup.sh 

如果出现以下错误

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

先看Tomcat的startup.bat,它调用了catalina.bat,而catalina.bat则调用了setclasspath.bat。只要在setclasspath.bat的开头声明环境变量,打开tomcat的bin目录下面的setclasspath.sh,添加红色部分,路径自己修改。windows  下用set,Linux下用export。

export JAVA_HOME=/usr/local/java/jdk1.8.0_121
export JRE_HOME=/usr/local/java/jdk1.8.0_121/jre

rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem ---------------------------------------------------------------------------
rem Set JAVA_HOME or JRE_HOME if not already set and ensure any provided
rem settings are valid and consistent with the selected start-up options.
rem ---------------------------------------------------------------------------

export JAVA_HOME=/usr/local/java/jdk1.8.0_121
export JRE_HOME=/usr/local/java/jdk1.8.0_121/jre


rem Make sure prerequisite environment variables are set

rem In debug mode we need a real JDK (JAVA_HOME)
if ""%1"" == ""debug"" goto needJavaHome

rem Otherwise either JRE or JDK are fine
if not "%JRE_HOME%" == "" goto gotJreHome
if not "%JAVA_HOME%" == "" goto gotJavaHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo At least one of these environment variable is needed to run this program
goto exit

:needJavaHome
rem Check if we have a usable JDK
if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
set "JRE_HOME=%JAVA_HOME%"
goto okJava

:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly.
echo It is needed to run this program in debug mode.
echo NB: JAVA_HOME should point to a JDK not a JRE.
goto exit

设置好后,保存当前配置文件。

[root@janus /]# /usr/local/tomcat/apache-tomcat-8.5.13/bin/startup.sh 
Using CATALINA_BASE:   /usr/local/tomcat/apache-tomcat-8.5.13
Using CATALINA_HOME:   /usr/local/tomcat/apache-tomcat-8.5.13
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.5.13/temp
Using JRE_HOME:        /usr/local/java/jdk1.8.0_121
Using CLASSPATH:       /usr/local/tomcat/apache-tomcat-8.5.13/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.5.13/bin/tomcat-juli.jar
Tomcat started.

继续执行tomcat中bin文件夹下的startup.sh

/usr/local/tomcat/apache-tomcat-8.5.13/bin/startup.sh 

然后通过浏览器访问

添加项目配置路径

#此配置在tomcat下的conf文件夹下,server.xml中的Host节点下添加项目文件名以及路径
<Context docBase="sparta" path="/sparta" debug="0" privileged="true"/>

 

共有 人打赏支持
粉丝 6
博文 23
码字总数 8322
×
투판시
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: