How to use IDEA to deploy a web project to a remote Tomcat server
Configure Tomcat server
The following will use
127.1.1.1
the 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
Open catalina.sh using vim editor
vim 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
Save and exit
Start the Tomcat server
./catalina.sh run
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
Save and exit
Configure the remote Tomcat server in IDEA
Select Edit configulations
Add remote Tomcat server
Create a new SFTP
and select the project to be deployed.
Modify the path mapping.
Save and deploy the project for testing
. Use IDEA to remotely deploy the project successfully.
At this time, the directory structure of webapps in the remote host