How to use IDEA to deploy a web project to a remote Tomcat server

How to use IDEA to deploy a web project to a remote Tomcat server


Configure Tomcat server

The following will use 127.1.1.1the public IP address as the remote host to perform operations to demonstrate
the port number used by Tomcat.80

Enter the bin directory under the tomcat installation directory

My tomcat installation path is:/usr/local/tomcat/apache-tomcat-8.5.53

input the command

cd /usr/local/tomcat/apache-tomcat-8.5.53/bin

Enter the bin directory under the tomcat installation directory

Open catalina.sh using vim editor

vim catalina.sh

catalina.sh

Add the following content at the beginning of the catalina.sh file

export CATALINA_OPTS="-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Djava.rmi.server.hostname=127.1.1.1" # 将127.1.1.1替换为你的公网IP地址

export JAVA_OPTS="-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.rmi.port=1099" 

1099 is the default port number for IDEA to remotely connect to the Tomcat server. It can be modified according to your own needs. Please
ensure that the corresponding port number is open and not blocked by the firewall
. If you use a cloud service provider's host, such as Alibaba Cloud,
please be sure to open it in the security group at the same time. Corresponding port

Modify catalina.sh file

Save and exit

Start the Tomcat server

./catalina.sh run

Start the Tomcat server

If you see the words on the last line of the output Server startup in xxxx ms, it means the server started successfully.

If you see the error: Error: Could not find or load main class, please check whether you added extra spaces when editing catalina.sh.

Note : No spaces can be added on both sides of the equal sign. It must be JAVA_OPTS="...", not be , and no extra spaces can appear after JAVA_OPTS = "..."the end of each line.'\'


Configure host name static query table

Use vim to open the /etc/hosts file

vim /etc/hosts

Add a record to the end of the file

127.1.1.1   localhost

Modify the /etc/hosts file
Save and exit


Configure the remote Tomcat server in IDEA

Select Edit configulations
Insert image description here
Add remote Tomcat server
Insert image description here
Insert image description here

Insert image description here
Create a new SFTP
Insert image description here
Insert image description here
Insert image description here
Insert image description here
and select the project to be deployed.
Insert image description here
Modify the path mapping.
Insert image description here
Save and deploy the project for testing
Insert image description here
. Use IDEA to remotely deploy the project successfully.

At this time, the directory structure of webapps in the remote host
Insert image description here

Guess you like

Origin blog.csdn.net/qq_44710943/article/details/109956399