This is the 22nd day of my participation in Gwen Challenge
Recently, I am making a class design. I want to write the background and the front end. It is more convenient to deploy to the server if we cooperate in development. So record the small white deployment background project to the server to step on the pit record.
This back-end project uses Springboot technology stack, uses Redis for cache, and mysql for database.
1. Package projects
1. The first step is to prepare projects that can run normally, and then package them directly in IDEA. Click the package of the project in Maven to package it.
After the package is complete, you can see the jar file in the target. Then save the JAR file and upload it to the server later
Two, set up the server
You can go to Ali cloud or Tencent cloud to buy a student server.
For example, I here is in Tencent cloud to buy, after buying can see in the example here there is a running 👇
Install Xshell and Xftp
Xshell is connected to the server for operation, can be said to manage the server. Xftp is used to upload files to the server. It works well together.
Xshell download and install
Xftp download and install
Connect to the server
After downloading, let’s connect to our server.
– Xshell connection
In the upper left corner of file -> New, fill in the following information and click OK, then click User Authentication on the left
If the connection is successful, it should display 👇
After the connection is successful, enter the command line similar to our Windows, in fact, Linux command line. We should have started the project at this point
But since my project is Springboot + Redis +mysql, SO I want to install Redis and mysql on the server without local
So next, install Redis and mysql on the server
1. Install and configure Redis
2. Install mysql
After installing mysql, remember to upload your local database to the server! (See Xftp below for uploading files)
– Xftp connection
Xftp connects to the server in a similar way to Xshell. After a successful connection, you will see the files on the server in the right panel.
The connection is successful, and then we can create a folder in it to upload files. Then we upload the jar suffix file packaged with idea in the first step to the server. You can specify your own path. Here I upload it to the home, drag the file directly to the home, and then start uploading.
After uploading, you can see our packed files. Back to Xshell, at this point both Redis and mysql should be installed and configured.
Then type it on the command line
cd ..
cd home
Copy the code
We went into the home folder, and then we looked to see if there were any files for us in the folder
ls
Copy the code
You can see our project file. And then start the project
Java-jar xxx.jar (project filename)Copy the code
If there is no problem with startup, 👇
Then open up the Swagger document and test it,
At this point, we have successfully deployed the backend project to the server. 👏 👏 👏
In this process, I encountered a lot of problems, and the process of finding out and solving problems one by one was quite interesting. I hope I can also help you in need