Linux Related: JDK1.8 installed Linux environment and Tomcat8

First, install the JDK

1. Download

Download jdk installation package Download the official website or download another version 1.8+

http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

Online Download:

# wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz


2 Install jdk
new Java usr directory below then create a new folder jdk and tomcat folder in the following Java


[the root @ iZj1fkye8uu7o0Z ~] # CD / usr
[the root @ iZj1fkye8uu7o0Z usr] # LS
bin etc games the include Java lib the lib64 libexec local sbin Share the src tmp
[the root @ iZj1fkye8uu7o0Z usr] # CD Java
[the root @ iZj1fkye8uu7o0Z Java] # LS
JDK Tomcat
create a directory mkdir java command mkdir tomcat and jdk and are used to extract the Tomcat
 [root @ localhost ~] # cd / usr /
 [root @ localhost usr] # mkdir java
 [root @ localhost usr] the Java # cd /
 [root @ localhost the Java] # mkdir jdk
 [root @ localhost the Java] # cd jdk
then extract to just download the jdk directory dk

Performs decompression command (if not this version, do not forget to change the file name) Note that the uppercase -C


[root @ iZj1fkye8uu7o0Z ~] # tar -xvf jdk-8u131-linux-x64.tar.gz -C / usr / java / jdk
decompression after entering the / usr / java / jdk just below can view the decompressed file

[iZj1fkye8uu7o0Z the root @ ~] # CD / usr / Java / JDK
[JDK iZj1fkye8uu7o0Z the root @] # LS
jdk1.8.0_131
[@ iZj1fkye8uu7o0Z the root JDK] # 
configure the environment variables 
configure an environment variable of the profile inside etc


[root@iZj1fkye8uu7o0Z ~]# vi /etc/profile
#set java enviroment
export JAVA_HOME=/usr/java/jdk/jdk1.8.0_131
export JRE_HOME=/usr/java/jdk/jdk1.8.0_131/jre
export CLASSPATH=.:$JAVA_HOME/lib$:JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin/$JAVA_HOME:$PATH

Note: Consistent here to download jdk jdk own name and the name of the version I use is jdk1.8.0_131

Save and exit.

So far jdk installation work has been completed, then test to see if the installation was successful, right


[iZj1fkye8uu7o0Z the root @ ~] # Java -version
[iZj1fkye8uu7o0Z the root @ ~] # -version Java
Java Version "1.8.0_131"
the Java ((TM)) the Runtime Environment SE (Build 1.8.0_131-B11)
the Java the HotSpot ((TM)) 64-Bit VM Server (Build 25.131-B11, the MODE Mixed)
[root @ iZj1fkye8uu7o0Z ~] # 
show version of jdk, then congratulations, you install jdk succeeded in Linux

Second, install tomcat
download tomcat 
first download the official online face of Tomcat tomcat http://tomcat.apache.org/download-80.cgi


Online Download:

[root @ iZj1fkye8uu7o0Z ~] # wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.tar.gz
The tomcat archive into the newly created tomcat folder


[root @ iZj1fkye8uu7o0Z ~] # tar -xvf apache-tomcat-8.5.14.tar.gz -C / usr / java / tomcat /
decompression success we can enter the / usr / java / tomcat below to see get such a file folder

[root @ iZj1fkye8uu7o0Z ~] # cd / usr / the Java / tomcat
[root @ iZj1fkye8uu7o0Z tomcat] # LS
apache-tomcat-8.5.14
[root @ iZj1fkye8uu7o0Z tomcat] #
The apache-tomcat-8.5.14 tomcat that we installed into the to this directory

[root @ iZj1fkye8uu7o0Z Tomcat] # cd the Apache-Tomcat-8.5.14
[root @ iZj1fkye8uu7o0Z the Apache-Tomcat-8.5.14] # LS
bin conf-lib the RELEASE LICENSE NOTICE logs in NOTES running.txt the TEMP webapps Work
[root @ iZj1fkye8uu7o0Z Apache - 8.5.14-tomcat] # 
1
2
3
4
5
you will see some of tomcat directory

  bin directory contains some of the script file Tomcat, the most important and most used is the start and relations tomcat service script.
  conf: all kinds of global storage Tomcat server configuration file, the most important is the server.xml and web.xml.
  webapps: The main Web Tomcat distribution directory, the default Web application files put in this directory.
  logs: Tomcat stored log file during execution
. 1
2
. 3
. 4
then proceeds to the next bin directory below the Tomcat

[root @ iZj1fkye8uu7o0Z the Apache-Tomcat-8.5.14] # cd bin /
[root @ bin iZj1fkye8uu7o0Z] # LS
bootstrap.jar catalina-Tasks.xml configtest.bat digest.bat setclasspath.sh startup.bat Tomcat-native.tar. version.bat GZ
the catalina.bat Commons-daemon.jar configtest.sh digest.sh the shutdown.bat the startup.sh Tool-wrapper.bat version.sh
the catalina.sh Commons-setclasspath.bat on a daemon-native.tar.gz daemon.sh Tomcat-juli.jar tool-wrapper.sh shutdown.sh
[root @ bin iZj1fkye8uu7o0Z] # 
1
2
3
4
5
6
7
you will see those files, so now edit setclasspath.sh script file, add this at the bottom of the two line configuration jdk

export JAVA_HOME=/usr/java/jdk/jdk1.8.0_131
export JRE_HOME=/usr/java/jdk/jdk1.8.0_131/jre
1
2
3


Start tomcat 
you find in the bin directory just below there are two script files startup.sh and shutdown.sh, based on a literal meaning to know that this is start the service, a service is shut down. So now to execute a script service startup.


[root@iZj1fkye8uu7o0Z bin]# ./startup.sh

[root @ bin iZj1fkye8uu7o0Z] # ./startup.sh
the Using CATALINA_BASE: /usr/java/tomcat/apache-tomcat-8.5.14
the Using CATALINA_HOME: /usr/java/tomcat/apache-tomcat-8.5.14
the Using CATALINA_TMPDIR: / usr / Java / Tomcat / Apache Tomcat-8.5.14-/ TEMP
the Using the JRE_HOME: /usr/java/jdk/jdk1.8.0_131/jre
the Using the CLASSPATH: /usr/java/tomcat/apache-tomcat-8.5.14/bin /bootstrap.jar:/usr/java/tomcat/apache-tomcat-8.5.14/bin/tomcat-juli.jar
Tomcat started.
[root @ bin iZj1fkye8uu7o0Z] # 
then started the Tomcat server
to verify 
access from a browser, enter http: // ip: 8080 can be accessed, if the outside can not access, but they can access the internal Linux, this is generally a firewall problem, turn off the firewall on it. 

Local Linux is localhost: 8080 localhost this is your local ip If you are a server, it's your guide public network ip services

If you enter the ip: port number is correct, and such a welcome page, then congratulations you have installed the Tomcat, then you can be happy to play up. 
Note If you need to change the port number or port number conflicts, and then want to be accessed directly or by ip do not want this port number 8080, then you only need to make changes in server.xml under conf which were


[root@iZj1fkye8uu7o0Z ~]# cd /usr/java/tomcat/apche-tomcat-8.5.14
-bash: cd: /usr/java/tomcat/apche-tomcat-8.5.14: No such file or directory
[root@iZj1fkye8uu7o0Z ~]# cd /usr/java/tomcat/apache-tomcat-8.5.14
[root@iZj1fkye8uu7o0Z apache-tomcat-8.5.14]# ls
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work
[root@iZj1fkye8uu7o0Z apache-tomcat-8.5.14]# cd conf
[root@iZj1fkye8uu7o0Z conf]# ls
Catalina         catalina.properties  jaspic-providers.xml  logging.properties  tomcat-users.xml  web.xml
catalina.policy  context.xml          jaspic-providers.xsd  server.xml          tomcat-users.xsd
[root@iZj1fkye8uu7o0Z conf]# 

In server.xml there may be many operations. 
Modify the port number


This port is connected to the back of your ip port number, modified to 8888 or 8081 will do, (provided that your 8080 port is occupied If you do not do not have to modify it), if you change became 80 for so long can be used directly ip plus access to a project name, because the browser is the default port 80 

Publish Project 
Your projects are on the webapps directory below

[root @ iZj1fkye8uu7o0Z the Apache-Tomcat-8.5.14] # cd webapps
[root @ iZj1fkye8uu7o0Z webapps] # LS
docs examples Host-Manager Manager ROOT
[root @ iZj1fkye8uu7o0Z webapps] # 
reveal a examples of this is the Tomcat Java project examples, can be accessed, ip: port / project name / -ip: 8080 / examples


By this time you have done, you can publish your own javaweb project to webapps below and then visit

Note 
1, if your Tomcat can be used, but add ip port is no way to display above the tomcat home page, you can see in the following web.xml conf inside inside a listings of whether true, false if it is modified to true

2, we have developed tools such as the eclipse as a war inside javaweb exported compressed file, we configure the server on top of Tomcat supports self-extracting compressed file war it also can be viewed at the following server.xml conf


That all things have a unpackWARs attribute is true it means that support automatic decompression war


If it is not the correct place to welcome comments


--------------------- 
Author:心静自然凉zc 
Source: CSDN 
Original: https: //blog.csdn.net/qq_39740187/article/details/80310549 
copyright Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin blog.csdn.net/writebook2016/article/details/86573838