How to build a tomcat container in CentOS

Source: Internet
Author: User
Tags centos tomcat


Here we need to configure the JDK1.8 + Tomcat 8 environment. Tomcat is a web container that runs web applaction.

1. Install JDK1.8
1. Download
Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Unable to directly obtain the download address, you can only download from the local machine before uploading the rpm package to the server.

Network Disk sharing address:
Jdk-8u45-linux-x64.tar.gz
Jdk-8u45-linux-x64.rpm

2. Uninstall OpenJDK

Rpm-qa | grep java

The old JDK version needs to be uninstalled online, if any.

3. Installation
Install after uploading:

# Rpm-ivh/tmp/jdk-8u45-linux-x64.rpm

Preparing... ######################################## ### [100%]
1: jdk1.8.0 _ 45 ##################################### ###### [100%]
Unpacking JAR files...
Rt. jar...
Jsse. jar...
Charsets. jar...
Tools. jar...
Localedata. jar...
Jfxrt. jar...
Plugin. jar...
Javaws. jar...
Deploy. jar...

The JDK installation path is/usr/java.

4. Verify that jdk is successfully installed.

# Java-version

Java version "1.8.0 _ 45"
Java (TM) SE Runtime Environment (build 1.8.0 _ 45-b14)
Java HotSpot (TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

5. Set environment variables

Vim/etc/profile
Join:
JAVA_HOME =/usr/java/jdk1.8.0 _ 45
JRE_HOME =/usr/java/jdk1.8.0 _ 45/jre
PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
Export JAVA_HOME JRE_HOME PATH CLASSPATH

6. Make the settings take effect

Source/etc/profile

7. View environment variables

Echo $ PATH

2. Install Tomcat 8
1. Download

Cd/tmp
Wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.23/bin/apache-tomcat-8.0.23.tar.gz
Tar-zxvf apache-tomcat-8.0.23.tar.gz
Mv apache-tomcat-8.0.23/usr/local/tomcat

2. Start Tomcat

/Usr/local/tomcat/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 _ 45/jre
Using CLASSPATH:/usr/local/tomcat/bin/bootstrap. jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

Tomcat started successfully.

Check whether the JAVA environment variables are correctly set and whether the firewall has enabled port 8080.

3. Stop Tomcat

/Usr/local/tomcat/bin/shutdown. sh

4. Add users in Tomcat

Vim/usr/local/tomcat/conf/tomcat-users.xml

Add the following to tomcat-users angle brackets:

<Role rolename = "manager-gui"/>
<User username = "tomcat" password = "123456" roles = "manager-gui"/>
<Role rolename = "admin-gui"/>
<User username = "admin" password = "123456" roles = "admin-gui"/>

Restart tomcat.

5. Visit the Tomcat homepage.
Http:/// IP: 8080

There are three options:
Server Status
Manager App
Host Manager

Manager-gui roles correspond to Server Status and Manager App
Admin-gui role corresponds to Host Manager

6. Put the test into the war package
1) drop the war package webapp1.war in the tomcat directory \ webapps \
2) restart Tomcat
3) access http: // IP: 8080/webapp1 in the browser to check whether the operation is successful.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.