Generate war package
First, we need to package the Web project into a war package
Connect to Linux server
Here we use the SSH client to connect to the remote Linux server. We need to know the Linux IP address, login user name, password, etc. in advance;
Commonly used SSH tools include Xshell, Xftp, etc., as well as MobaXterm, etc.
Here is demonstrated through the MobaXterm tool:
If you have not installed or used this MobaXterm tool, you can refer to this article: Remote tool MobaXterm installation
Open the MobaXterm tool and select Session:
Enter the Linux IP address and click OK to connect:
After the connection is successful, you will enter the command line terminal. We can enter the user name and password (the password is hidden by default, just enter it normally):
After the username and password are verified, we officially enter the command line window:
Enter the Tomcat container
Next, we need to enter the directory where Tomcat is located on Linux (if it is not installed, you need to install Tomcat on Linux first). Of course, the premise is that we need to know the directory where tomcat is located. For example, here is /usr/local/tomcat ;Then I will enter through the command: cd /usr/local/tomcat:
For convenience, we need to keep the folder on the left and the command line window synchronized for subsequent file operations. Check the following buttons:
Close original service
Before deploying the war package, we need to shut down the originally started tomcat, otherwise when you start it new, the startup may fail due to port occupation;
We first use the ps -ef | grep tomcat command to check whether there is a started tocmat, and make sure it is the tomcat started in the current directory.
You can see that tomcat is already running in the directory to be deployed. We run: ./shutdown.sh to shut it down:
Back up the original War package
Then we enter the tomcat webapps directory:
You can see the previously deployed war package and the files decompressed after running. We need to back up the previous war package first (it can be rolled back if an upgrade error occurs).
Deploy new War package
Then, in the file operation window on the left, we delete the original war package through the toolbar, and then upload the previously prepared war package.
Start Tomcat
After deploying the new war package to the webapps directory, we return to the bin directory and start tomcat through the ./startup.sh command:
At this point, tomcat has been successfully started!
Check the startup log to ensure normal startup
If after tomcat starts successfully, we first check the real-time log after startup. What should we do?
We can enter the log directory and use the tail -f -n 100 catalina.out command to view the last 100 real-time log information and support dynamic refresh:
Use the lina.out command to view the last 100 log messages in real time and support dynamic refresh:
[External link pictures are being transferred...(img-aV5FKy3m-1688708578239)]
If you don’t want to read it, you can use ctrl + C to stop the above query.