Install JDK and Tomcat in Linux

Source: Internet
Author: User

Install JDK and Tomcat in Linux


View environment variables
Whereis java
Which java (java execution path)
Echo $ JAVA_HOME
Echo $ PATH

Ii. Installation
Select the location where you want to install java, such as in the/usr/directory, and create a folder named java (mkdir java)

# Mkdir-p/usr/java
Download jdk-8u31-linux-x64.tar.gz to/usr/java.

# Cd/usr/java
# Tar-zxvf jdk-8u31-linux-x64.tar.gz

3. Set Variables
# Vim/etc/profile
Add the following content at the end:
# JAVA
JAVA_HOME =/usr/java/jdk1.8.0 _ 31
CLASSPATH =.: $ JAVA_HOME/lib. tools. jar
PATH = $ JAVA_HOME/bin: $ PATH
Export JAVA_HOME CLASSPATH PATH

Make variables take effect
# Source/etc/profile

Verify whether it is successful
# Java-version
Java version "1.8.0 _ 31"
Java (TM) SE Runtime Environment (build 1.8.0 _ 31-b13)
Java HotSpot (TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

View Variables
# Which java // java execution path
/Usr/java/jdk1.8.0 _ 31/bin/java
# Echo $ JAVA_HOME
/Usr/java/jdk1.8.0 _ 31
# Echo $ PATH
/Usr/java/jdk1.8.0 _ 31/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/root/bin


4. Uninstall jdk
· Find the _ uninst subdirectory of the jdk installation directory.
· Run the command./uninstall. sh on the shell terminal to uninstall jdk.

5. install tomcat
Download tomcat
Wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.20/bin/apache-tomcat-8.0.20.tar.gz

(1)decompress apache-tomcat-8.0.20.tar.gz
# Tar-zxvf apache-tomcat-8.0.20.tar.gz
(2) copy the decompressed directory apache-tomcat-8.0.20 to/usr/local and rename it tomcat8.
# Cp-Rapache-tomcat-8.0.20/usr/local/tomcat8
Note:/usr/local/tomcat8 is the directory path we need to fill in when modifying the environment variables.
(3)
Add tomcat Environment Variables
# Vim/etc/profile
Add code
# Set environment variable
JAVA_HOME =/usr/java/jdk1.8.0 _ 31
CLASSPATH =.: $ JAVA_HOME/lib. tools. jar
PATH = $ JAVA_HOME/bin: $ PATH
Export JAVA_HOME CLASSPATH PATH
ExportTOMCAT_HOME =/usr/local/tomcat8
ExportCATALINA_HOME =/usr/local/tomcat8
Modify the application environment variable to make the configuration take effect
# Source/etc/profile

(4) enter the bin directory and start tomcat
# Cd/usr/local/tomcat8/
# Cd bin/
#./Startup. sh

(5) modify the environment variable and restart tomcat.
[Root @ oracledb bin] #./startup. sh
Using CATALINA_BASE:/usr/local/tomcat8
Using CATALINA_HOME:/usr/local/tomcat8
Using CATALINA_TMPDIR:/usr/local/tomcat8/temp
Using JRE_HOME:/usr/java/jdk1.8.0 _ 31
Using CLASSPATH:/usr/local/tomcat8/bin/bootstrap. jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Tomcat started.

(6) Disable tomcat
[Root @ oracledb bin] #./shutdown. sh
Using CATALINA_BASE:/usr/local/tomcat8
Using CATALINA_HOME:/usr/local/tomcat8
Using CATALINA_TMPDIR:/usr/local/tomcat8/temp
Using JRE_HOME:/usr/java/jdk1.8.0 _ 31
Using CLASSPATH:/usr/local/tomcat8/bin/bootstrap. jar:/usr/local/tomcat8/bin/tomcat-juli.jar

(7) view Processes
[Root @ oracledb bin] # ps-ef | grep tomcat
Root 22552 1 99 09:58 pts/0 00:00:05/usr/java/jdk1.8.0 _ 31/bin/java-Djava. util. logging. config. file =/usr/local/tomcat8/conf/logging. properties-Djava. util. logging. manager = org. apache. juli. classLoaderLogManager-Djava. endorsed. dirs =/usr/local/tomcat8/endorsed-classpath/usr/local/tomcat8/bin/bootstrap. jar:/usr/local/tomcat8/bin/tomcat-juli.jar-Dcatalina. base =/usr/local/tomcat8-Dcatalina. home =/usr/local/tomcat8-Djava. io. tmpdir =/usr/local/tomcat8/temp org. apache. catalina. startup. bootstrap start
Root 22581 22284 0 00:00:00 pts/0 grep tomcat

(8) 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.







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.