1. Download related software
JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Tomcat: http://mirrors.shuosc.org/apache/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz
2. Install and configure JDK
[root@JDK-Tomcat ~]# rpm -ivh jdk-8u151-linux-x64.rpm
Add the following three lines to /etc/profile:
[root@JDK-Tomcat ~]# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_151
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH
Check the installation details.
[root@JDK-Tomcat ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
3. Install and configure Tomcat
1. Download and install Tomcat.
[root@JDK-Tomcat ~]# wget -c http://mirrors.shuosc.org/apache/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz
[root@JDK-Tomcat ~]# tar -xzvf apache-tomcat-9.0.2.tar.gz
[root@JDK-Tomcat ~]# mkdir /usr/local/tomcat
[root@JDK-Tomcat ~]# mv apache-tomcat-9.0.2 /usr/local/tomcat/
[root@JDK-Tomcat ~]# cd /usr/local/tomcat/apache-tomcat-9.0.2/
2. Modify the configuration system settings and start Tomcat.
[root@JDK-Tomcat apache-tomcat-9.0.2]# vi /etc/profil
export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-9.0.2/
[root@JDK-Tomcat bin]# source /etc/profile
[root@JDK-Tomcat bin]# ./catalina.sh start
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.2
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.2
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.2/temp
Using JRE_HOME: /usr/java/jdk1.8.0_151
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-9.0.2/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-9.0.2/bin/tomcat-juli.jar
Tomcat started.
Enter the server IP address in the browser, default port 8080, to see if the following page appears:
Installation was successful, as shown in the figure above.
4. Stop Tomcat and further modify the configuration.
[root@JDK-Tomcat bin]# ./shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.2
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.2
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.2/temp
Using JRE_HOME: /usr/java/jdk1.8.0_151
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-9.0.2/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-9.0.2/bin/tomcat-juli.jar
1. Modify the default listening port, for example, by changing port 8080 to 80 and replacing 8080 in the configuration file with 80.Start Tomcat to remove the port number view.
[root@JDK-Tomcat bin]# vim /usr/local/tomcat/apache-tomcat-9.0.2/conf/server.xml
:1,$s/8080/80/
2. Modify character encoding.Add the highlighted part code to the part shown in the figure, save the exit, and restart Tomcat.
3. Set Tomcat to start automatically.
In/usr/local/tomcat/apache-tomcat-9.0.2/bin/Startup.shAdd the following four lines to the end of Save Exit!
export JAVA_HOME=/usr/java/jdk1.8.0_151
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH=$JAVA_HOME/bin
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.2/bin/catalina.sh start
Edit/etc/rc.d/Rc.localConfiguration file.Add the following line, save and exit!
/usr/local/tomcat/apache-tomcat-9.0.2/bin/startup.sh
4. Optimize.In/usr/local/tomcat/apache-tomcat-9.0.2/bin/Catalina.shAdd the following line:
JAVA_OPTS="-XX:MaxPermSize=192M -Xms1000M -Xmx2000M"
Shut down the server and restart to see if it starts properly?