Deploying Javaweb Engineering on Tomcat in a Linux environment

Source: Internet
Author: User

This article explains how to deploy our compiled Javaweb project to Tomcat in a Linux environment, with the overall idea of deploying the Javaweb project to Tomcat in the same way as in Windows, with the following steps and commands.
Note: The JDK must already be installed on Linux before deployment, specifically on how to install the JDK on Linux see: Installing the JDK in a Linux environment

1 Preparatory work

1, download installs Xshell, XFTP (for the remote connection Linux host, the specific self-Baidu)
2, the official website download Linux under the Tomcat installs the package, I use is: apache-tomcat-6.0.45.tar.gz, the direct click can download, of course also can directly to the official website to download: http://tomcat.apache.org/
3, the Javaweb project packaging, such as My project is Cucpayperson, WebApp or Webroot file package into CucPayPerson.tar.gz (this is my practice, and the general practice is to fight the war package)

2 Uploading the engineering code and the Tomcat installation package to the Linux environment

1. Create the Project Deployment directory:

mkdir /app/code
    • 1

2. Upload the package code file CucPayPerson.tar.gz to the above directory with XFTP
3, Decompression:

tar  -xvzf  CucPayPerson.tar.gz
    • 1

4, the final Windows and Linux under the project file system structure comparison is as follows:

3 Installing Tomcat

1. Create a new Tomcat server directory:

mkdir /app/tomcat
    • 1

2. Unzip the file:

tar  xvf  apache-tomcat-6.0.45.tar.gz
    • 1

To the above directory, this time the Tomcat path is:/app/tomcat/apache-tomcat-6.0.45
3. Change the Tomcat folder: apache-tomcat-6.0.45 to Project name: Cucpayperson

mv /app/tomcat/apache-tomcat-6.0.45 /app/tomcat/CucPayPerson
    • 1

This is because the Linux environment deploys a lot of projects, then we will install a Tomcat server for each project, so a name, the Tomcat path is:/app/tomcat/cucpayperson, the directory structure is as follows:

4 Modifying the Tomcat configuration file

Major changes in port and project deployment paths in Server.xml
1. Enter the Conf folder in Tomcat:

cd /app/tomcat/CucPayPerson/conf
    • 1

2, modify the content of Server.xml, the implementation:

vi  server.xml
    • 1

Then press I to enter the modification:

Modify the following three parts, click ESC after the modification is complete, and then enter: Wq this saves the exit.
To modify the Shutdown stop service port:

<Server port="9001" shutdown="SHUTDOWN">
    • 1

To modify the Web login port:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    • 1
    • 2
    • 3

To modify the project publishing path:

<Host>    <Context path="/per" docBase="/app/code/CucPayPerson" debug="0" privileged="true" reloadable="false" /></Host>
    • 1
    • 2
    • 3

Note: If you have multiple Tomcat servers installed for multiple projects, you must ensure that the shutdown service port and the Web landing port are different, and that the project release path is the project code path above

5 starting and stopping the Tomcat server

1. Enter the Tomcat startup directory:

cd  /app/tomcat/CucPayPerson/bin
    • 1

The bin directory has the following files, you can see that there are some of this file, where startup.sh and shutdown.sh are start and stop scripts, respectively

2. Execute the Start command:

nohup  ./startup.sh  &
    • 1

The./means to execute the current path under the script file, nohup means the background execution

3. Stop command

shutdown.sh
    • 1

Or:

shutdown.sh
    • 1
6 trace log commands during startup

1. Enter the Tomcat log directory:

cd  /app/tomcat/CucPayPerson/logs
    • 1

2. Execute trace log command

tail -100f catalina.out
    • 1

This command means to dynamically flush the last 100 lines of the trace file Catalina.out

7 See if the project is started

1. Query the project process

ps  -ef|grep  CucPayPerson
    • 1

2. Whether the test service has been successfully started
Browser input: Http://10.1.7.88:8080/per, change to the IP or domain name of the Linux host.

8 Mandatory Kill Project Process

In addition to using Tomcat's stop command to stop the project service, you can also kill the process by checking the process ID
1, first get the project process ID

| grep CucPayPerson
    • 1

2, according to process ID kill process

kill -9 进程号
    • 1

Over

http://blog.csdn.net/trigl/article/details/51138640//Original

Deploying Javaweb Engineering on Tomcat in a Linux environment

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.