Tomcat server Building and deployment of Web applications

Source: Internet
Author: User

First create a virtual machine, I use the virtual machine version is CentOS7

Uploading compressed packages from Oracle JDK and Tomcat servers to the server

Installing Oracle JDK
1. First create a folder in the USR directory Java

sudo mkdir –p  /usr/java


2. Enter the following command to unzip:

sudo tar -zxvf /home/user/jdk-8u161-linux-x64.tar.gz  -C /usr/java/

Extract the following as shown:

3. Configure environment variables for the JDK

export JAVA_HOME=/usr/java/jdk1.8.0_161export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=.:${JAVA_HOME}/bin:$PATH


4. Make the configuration in/etc/profile effective immediately

source  /etc/profile

5. Test if Java is installed successfully

java -version

Installing the Tomcat server
1. Unzip the tomcat to the specified folder (I unzipped to the/home/user folder)

2. The following folder (apache-tomcat-9.0.6) appears when you unzip into the USR directory

    1. Modify the Server.xml configuration file and add the following statement:
      <Context path="" docBase="/home/user/apache-tomcat-9.0.6/webapps/" debug="0" reloadable="true" crossContext="true"/>    #其中docBase是我的Tomcat目录

4. Turn off the CentOS firewall
(1) View firewall status first

systemctl status firewalld.service


(2) Turn off firewall and disable boot firewall

systemctl stop firewalld.servicesystemctl disable firewalld.service


Tomcat Server startup and shutdown
1. Start the Tomcat server
Enter the bin directory of the Tomcat server, and then execute the "./startup.sh" command to start the Tomcat server as shown in:

(1) Check the log information of the Tomcat server to see if the Tomcat server has started properly, enter the logs directory under the Tomcat server and open the Catalina.out file for viewing, as shown in:

(2) In the browser input ip:8080 can be seen as shown:

(3) In WebApps Create a file HelloWorld, test tomcat has no success

cd /home/user/apache-tomcat-9.0.6/webapps/vim HelloWorld

What is written in the HelloWorld file

Accessing Ip:8080/helloworld on the browser appears as shown:

Indicates that the Tomcat server has started successfully.
If Tomcat does not boot, it is most likely that the port used at startup is occupied by other applications, so you can troubleshoot it by looking at the application that 8080 port is taking up, for example.

2. Close the Tomcat server
Enter the bin directory of the Tomcat server, and then execute the "./shutdown.sh" command to start the Tomcat server as shown in:

Check the log information of the Tomcat server to see if the Tomcat server has shut down properly, go to the logs directory under the Tomcat server, open the Catalina.out file for viewing, as shown in:

Deploying Javaweb to a Tomcat server
Deploying Javaweb to a Tomcat server is to package an open Javaweb application into a war package and publish it to the WebApps directory of the Tomcat server

Packaged Javaweb applications
Open Eclipse, right-click Project Select the War file from the export

then click Finish.

This is the packaged war package.

Publish the war package to the Tomcat server
1. Upload the packaged war package to the Tomcat server WebApps directory as shown in:

2. Upload Success
Tomcat server automatically unzip the war package

3. Then visit ip:8080/portal The following screen appears:

The installation of the Tomcat server and deployment of the Web application is complete

Tomcat server Building and deployment of Web applications

Related Article

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.