Install Tomcat and configure the JDK environment in CentOS

Source: Internet
Author: User
Tags nginx reverse proxy

Install Tomcat and configure the JDK environment in CentOS

Step 1: Download JDK and Tomcat
Download JDK
Https://edelivery.Oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm
Or: # wget https://edelivery.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.rpm
Version: jdk-7u45-linux-x64.rpm
Install JDK
[Root @ thinkpig00ss] # rpm-ivhjdk-7u45-linux-x64.rpm
Download tomcat7
Http://apache.fayea.com/apache-mirror/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
Or:
# Wget http://apache.fayea.com/apache-mirror/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
Version: apache-tomcat-7.0.47.tar.gz
Step 2. Uninstall the old tomcat
Uninstall Tomcat 6 automatically installed with yum
# Yum remove tomcat6
View the local jdk version
# Java-version
[Root @ thinkpig007 ss] # java-version
Java version "1.6.0 _ 24"
OpenJDK Runtime Environment (IcedTea6 1.11.13) (rhel-1.65.1.11.13.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build between 0-b12, mixed mode)
[Root @ thinkpig007 ss] #
View the JDK version installed on the local machine
[Root @ thinkpig007 ss] # cd/usr/java/
Default/jdk1.7.0 _ 45/latest/
Note: The jdk directory here is the path and directory name to be filled in when we modify the/etc/profile environment variable.
ExportJAVA_HOME =/usr/java/jdk1.7.0 _ 45
(Details: "(4) add tomcat environment variables" in "step 3, install tomcat 7 ")
[Root @ thinkpig007 ss] # cd/usr/java/
[Root@thinkpig007jdk1.7.0 _ 45] # cat release
JAVA_VERSION = "1.7.0"
OS _NAME = "Linux"
OS _VERSION = "2.6"
OS _ARCH = "amd64"
SOURCE = ".: Role: includeploy: 2b1995e2c8f5 hotspot: Role/make/closed: Role hotspot/src/closed: Role/test/closed: 47eee40b7622 install: 99193876e329 jaxp: Role jdk: c5ca4daec23b jdk/make/closed: Pushed/src/closed: b6108fd9ff72 jdk/test/closed: e3c74041acc5 langtools: ba3ff27d4082pubs: 476da1da84f7 supervisor SORS: Pushed"
BUILD_TYPE = policcial
Step 3. install Tomcat 7
Install tomcat
(1)decompress apache-tomcat-7.0.47.tar.gz
[Root @ thinkpig007 ss] # tar-zxvf apache-tomcat-7.0.47.tar.gz
(2) copy the decompressed directory apache-tomcat-7.0.47 to/usr/local and rename it as tomcat7.
[Root @ thinkpig007 ss] # cp-Rapache-tomcat-7.0.47/usr/local/tomcat7
Note:/usr/local/tomcat7 is the directory path to be filled in when we want to modify the environment variable.
(3) enter the bin directory
[Root @ thinkpig007 ss] # cd/usr/local/tomcat7/
[Root @ thinkpig007 tomcat7] # cdbin/
[Root @ thinkpig007 bin] #
An error occurred while starting tomcat before modifying environment variables.
[Root @ thinkpig007 bin] #./startup. sh
Cannot find "/usr/local/tomcat"/bin/setclasspath. sh
(4) add tomcat Environment Variables
# [Root @ thinkpig007 ~] # Vi/etc/profile
Add code
# Set environment variable
ExportJAVA_HOME =/usr/java/jdk1.7.0 _ 45
Export CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
ExportTOMCAT_HOME =/usr/local/tomcat7
ExportCATALINA_HOME =/usr/local/tomcat7
ExportPATH = $ PATH: $ JAVA_HOME/bin
(5) modify the application environment variable to make the configuration take effect.
[Root @ thinkpig007 bin] # source/etc/profile
(6) modify the environment variable and restart tomcat to start successfully.
This file is needed to runthis program
[Root @ thinkpig007 bin] #./startup. sh
Using CATALINA_BASE:/usr/local/tomcat7
Using CATALINA_HOME:/usr/local/tomcat7
Using CATALINA_TMPDIR:/usr/local/tomcat7/temp
Using JRE_HOME:/usr/java/jdk1.7.0 _ 45
Using CLASSPATH:/usr/local/tomcat7/bin/bootstrap. jar:/usr/local/tomcat7/bin/tomcat-juli.jar


(7) Disable tomcat
[Root @ thinkpig007 bin] #./shutdown. sh
Using CATALINA_BASE:/usr/local/tomcat7
Using CATALINA_HOME:/usr/local/tomcat7
Using CATALINA_TMPDIR:/usr/local/tomcat7/temp
Using JRE_HOME:/usr/java/jdk1.7.0 _ 45
Using CLASSPATH:/usr/local/tomcat7/bin/bootstrap. jar:/usr/local/tomcat7/bin/tomcat-juli.jar
[Root @ thinkpig007 bin] #
Step 4: add management Permissions
By default, Tomcat does not provide an account with administrative permissions, so you need to add an account with such permissions. Role manager-gui has this permission, but the two roles and their corresponding users are not set in the System user control file tomcat-users.xml, so you need to add such roles and users, to open the tomcat-users.xml file, add the following:
<Rolerolename = "manager-gui"/>
<Userusername = "manager" password = "manager" roles = "manager-gui"/>
Restart the Tomcat server, and the file modification takes effect.

Tomcat details: click here
Tomcat: click here

Load Balancing between Apache and multiple Tomcat clusters in Linux

Nginx Tomcat Cluster load balancing solution notes

Instance details Tomcat component installation + Nginx reverse proxy Tomcat + Apache use mod_jk and mod_proxy Reverse Proxy and load balancing

Build an Apache + Tomcat environment (JK deployment process)

In-depth analysis of Tomcat PDF

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.