Explain the installation and configuration of JDK and Tomcat under Linux
- 2020-05-30 21:59:12
- OfStack
1. Installation of jdk
1.1 download jdk
Check first how many bits (32-bit / 64-bit) the Linux system is: getconf LONG_BIT. Again from JDK website (http: / / www. oracle. com/technetwork/java/javase downloads/jdk7 - downloads - 1880260. html) download JDK 7, 64 download jdk Linux - 7 u60 - linux - x64. tar. gz.
1.2 decompression installation
1.2.1 select the location /usr/Java where JDK is installed. If there is no need to create this directory, the newly arrived machine does not have this directory. For this, we will create this directory.
sudo mkdir /usr/java
1.2.2 upload jdk-7u60-linux-x64.tar.gz to the server and move it to /usr/java.
sudo mv jdk-7u60-linux-x64.gz /usr/java
1.2.3 unzip: enter the /usr/java directory (cd usr/java) to unzip
sudo tar -zxvfjdk-7u60-linux-x64.gz
1. Remove jdk - 7 u60 - linux - x64. tar. gz
1.3 configure environment variables
Open /etc/profile (sudo vim /etc/profile) and add the following at the end:
export JAVA_HOME=/usr/java/jdk1.7.0_60
export JRE_HOME=/usr/java/jdk1.7.0_60/jre
exportCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
Enable configuration:
source /etc/profile
1.4 validation
java � version
Print the currently installed jdk version java version "1.7.0_60"
2. Installation of tomcat
2.1 download tomcat
From tomcat website (http: / / tomcat. apache. org/download - 70. The cgi) compressed package download tomcat apache - tomcat - 7.0.54. tar. gz. The website has three parts, Binary Distributions, Deployer and Extras, which are explained as follows:
Binary Distributions
Core:
zip (pgp, md5)
tar.gz (pgp, md5)
32-bit Windows zip (pgp, md5)
64-bit Windows zip (pgp, md5)
64-bit Itanium Windows zip (pgp, md5)
32-bit/64-bit Windows Service Installer (pgp, md5)
Full documentation:
tar.gz (pgp, md5)
Deployer:
zip (pgp, md5)
tar.gz (pgp, md5)
Extras:
JMX Remote jar (pgp, md5)
Web services jar (pgp, md5)
JULI adapters jar (pgp, md5)
JULI log4j jar (pgp, md5)
Embedded:
tar.gz (pgp, md5)
zip (pgp, md5)
zip for the windows operating system, tar.gz for the unix and linux operating systems.
Binary Distributions Core: run the installation file directly under this column.
Deployer: files for programmers to program under this column.
Source Code Distributions: the source code for tomcat under this column.
2.2 decompression installation
2.2.1 upload apache-tomcat-7.0.54.tar.gz to the server and move it to /usr/local
sudo mv apache-tomcat-7.0.54.tar.gz/usr/local/
2.2.2 enter /usr/local directory (cd /usr/local/) to unzip
sudo tar -zxvf apache-tomcat-7.0.54.tar.gz
2.2.3 rename apache-tomcat-7.0.54 to tomcat
mv apache-tomcat-7.0.54 tomcat
2.2.4 delete apache tomcat - 7.0.54. tar. gz
2.3 modify the port of tomcat
Enter cd usr/local/apache - tomcat - 7.0.42 conf/directory, open the server. xml (sudo vim server. xml) to modify the port 8080 to 8081.
sudo mv jdk-7u60-linux-x64.gz /usr/java
0
2.4 validation
Switch to the root users under sudo � i, start tomcat (/ usr/local/apache - tomcat - 7.0.42 / bin/startup sh), in the browser input http: / / localhost: 8081 / see tomcat welcome page. localhost is replaced by Linux server IP.
2.5tomcat memory optimization
The Tomcat memory optimization is mainly about the tomcat startup parameters. We can set the JAVA_OPTS parameter in the tomcat startup script catalina.sh. My server is 6G memory, so I set the JVM startup parameter to be larger, and I can set it according to my actual situation.
JAVA_OPTS='-Xms2048m -Xmx4096m -Xmn1g-Xss1024k -XX:NewRatio=4 -XX:SurvivorRatio=4 -XX:PermSize=1024m-XX:MaxPermSize=1024m -XX:MaxTenuringThreshold=0 -XX:+UseParallelGC-XX:ParallelGCThreads=20 -XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy'