How to deploy a project on a Linux tomcat server

Source: Internet
Author: User
Tags tomcat server

The premise of deploying the project on the Tomcat server is that we have the Tomcat server ready. Deploying the Javaweb environment in a centos environment, deploying a Tomcat server has been summarized in the previous article, and can refer to previous articles.

A tomcat server modifies the port

After the Tomcat server is configured, the default is port 8080, and for easy access, we modify the port to 80 ports. For example, Tomcat is installed in the/usr/local/tomcat directory, using commands

#cd/usr/local/tomcat/conf

#ls

Files in the Conf directory can be tomcat, the port definition is in the Server.xml file, using

#vi Server.xml

Go to Server.xml to modify, find in file

<connector port= "8080" protocol= "http/1.1"

connectiontimeout= "20000"

redirectport= "8443"/>

Input "i" switch to the input mode, the port= "8080" to port= "80", press ESC exit key, cut back to the command mode, enter ":", switch to the last line mode, enter "Wq", return, equivalent to save exit, so that the port of Tomcat is completed.

Then restart the Tomcat server for the changes to take effect.

Enter the Tomcat bin directory first

#cd/usr/local/tomcat/bin

Close Tomcat

#./shutdown.sh

Start Tomcat

#./startup.sh

Because port 80 is the default port, we use the HTTP protocol to access the server when the port is not added, you can directly enter the server's IP to access.

Two build Java project deployment files (clip)

Project completion part of the function, want to put on the Tomcat server test, can generate a war file, but the package of war file is relatively large, if the test on the public server need to upload a long time, I use the whole compiled folder upload server, because the file is separate, On the first upload will take a long time, after only a change of part of the file (mainly binary classes file), the amount of data will be relatively small, upload will be very fast.

First of all, I am using the Java development tool is the Eclipse Neon version, Java JDK is 1.8 (jdk1.8.0_101), Tomcat is version 8.0 (apache-tomcat-8.0.36). To get the project deployment folder, you need to know the working directory of Tomcat used on eclipse, the working directory of the Tomcat server can be set in Eclipse, the working directory setting reference

http://blog.csdn.net/xiaojiang167168/article/details/25330899

The following text references

Tomcat Service settings in eclipse
Select window----show view---services to see a panel of services
Double-click Tomcat to enter the Configuration Interface service Locations (Specify the server path (i.e.catalina.base) and deploy path. The Server must is published with the no modulespresent to make changes.) option dimmed the configuration cannot be changed.
To change, remove all items under Tomcat first. And right-click, clean ... Before you can set ... It turns black again when it starts.

The default options are:
Use workspace metadata (dose not modify Tomcat installation)
The modification options are:
Use Tomcat installation (takes control of Tomcat installation)


This enables the Tomcat server to be launched in Eclipse, and we can also access the Tomcat local admin home page.

After the setup is complete, the Tomcat server's working directory is the Tomcat installation directory, for example, my Tomcat is installed in the E:\apache-tomcat-8.0.36 directory, and after we start the server, Tomcat will put our project into E:\ Apache-tomcat-8.0.36\wtpwebapps directory, the name of the folder is the project name, if our project name is Project1, in the Wtpwebapps folder there is a Project1 folder, This folder is the file we need to deploy.

Three deployment project folders to the Tomcat server

After launching the Tomcat service in Eclipse, you can access the Http://localhost/project1 directly, if you have defined some application interfaces in the project, you can access directly, such as the user login interface is login, we can access HTTP/ Localhost/project1/login.

It is also easier to deploy the Tomcat folder to the Tomcat server, which is to copy the Project1 folder directly to the Tomcat WebApps folder. You can use the Linux communication tool ssh to upload the Project1 folder to the Linux/usr/local/tomcat/webapps folder so that you can access the project directly through the HTTP://IP address/project1.

Open the project folder, we will find that it will have Meta-inf, web-inf two folders, there may be some other resources folder, these other folders or files are we compile in eclipse in the WebApp (or Webroot) created inside. After the first upload, these files (folders) are uploaded to the server with the project folder, after uploading again we generally only need to upload the classes folder under the Web-inf folder, because the other files will not change, of course, if changed also overwrite upload can be.

One thing to note here is that the process of uploading the classes folder, because the inside is a binary file, Tomcat may be in use, so can not be deleted, can not be overwritten, you need to manually delete this folder.

Enter the Web-inf directory

#cd/usr/local/tomcat/webapps/project1/web-inf

Delete Classes Folder

#rm –RF Classes

Then copy the Classes folder under the compiled directory to the server Web-inf directory. Then you'll restart Tomcat.

#cd/usr/local/tomcat/bin

#./shutdown.sh

#./startup.sh

In this way, the modification is complete.

How to deploy a project on a Linux tomcat server

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.