1. 程式人生 > >Centos6.5下Tomcat安裝及配置

Centos6.5下Tomcat安裝及配置

tsp watermark ext name mode export f2c images centos6

一、安裝前準備

安裝Tomcat需要提供JDK支持

下載JDK安裝包

#wget https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm?AuthParam=1543443708_da2f2c188434950c40633b9ddee08967

安裝JDK

# rpm -ivh jdk-8u191-linux-x64.rpm

設置環境變量

#  vim /etc/profile
文檔最後添加如下內容:
export JAVA_HOME=/usr/java/jdk1.8.0_191-amd64
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

檢查JDK是否安裝成功

# java -version
如果看到JVM版本及相關信息,即安裝成功!
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)

二、安裝Tomcat7

下載安裝包

# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz

解壓安裝包

# tar -xzf apache-tomcat-7.0.92.tar.gz

移動解壓包至文件目錄

# mv apache-tomcat-7.0.92 /usr/local/

更改文件名稱

# cd /usr/local
# mv apache-tomcat-7.0.92/ apache-tomcat/

修改啟動文件catalina.sh

# cd apache-tomcat/bin
# vim catalina.sh
添加以下內容:
CATALINA_HOME=/usr/local/apache-tomcat/
# chmod +x catalina.sh 

啟動測試Tomcat

# ./catalina.sh start
http://localhost:8080,測試成功。

登錄管理界面

技術分享圖片

添加用戶

# vim /usr/local/apache-tomcat/conf/tomcat-users.xml
    -->後添加如下內容:
    -->
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <user username="admin" password="redhat" roles="manager-gui"/>

登錄測試

# /usr/local/apache-tomcat/bin/catalina.sh stop
# /usr/local/apache-tomcat/bin/catalina.sh start
http://localhost:8080

Centos6.5下Tomcat安裝及配置