Install JDK and Tomcat__linux under Linux (CentOS7.2)

Source: Internet
Author: User
First, download the relevant 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 II Installation and configuration JDK

Add the following three lines to the/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)
Third, 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 configuration system settings, 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.

In the browser, enter the server IP address, default port 8080, and see if the following page appears:

If the above illustration shows, the installation is successful.
4, stop Tomcat, 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: 8080 port modified to 80, the configuration file 8080 replaced by 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 the character encoding. Add the highlighted part of the code, save the exit, and restart Tomcat as shown in the figure.

3, set up tomcat boot.
Add the following four lines to the tail of the/usr/local/tomcat/apache-tomcat-9.0.2/bin/startup.sh and save the 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 the/etc/rc.d/rc.local configuration file. Add the following line to save the exit.

/usr/local/tomcat/apache-tomcat-9.0.2/bin/startup.sh

It's important to add executive authority to/etc/rc.d/rc.local, and don't forget. Otherwise it will not be executed.

4, optimization. Add the following line to/usr/local/tomcat/apache-tomcat-9.0.2/bin/catalina.sh:

Java_opts= "-xx:maxpermsize=192m-xms1000m-xmx2000m"

Turn off the server and reboot to see if the boot is normal.

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.