Quickly build a personal website on the server (SpringBoot project)

buy your own server

Here I choose the Alibaba Cloud server. Go to the official website of Alibaba Cloud https://www.aliyun.com . Generally, Alibaba Cloud provides several servers, cloud server ESC, lightweight application server, ESC is better, in general There are exclusive activities for newcomers, which are relatively cheap:
insert image description here

Here I have purchased an ESC server for 1 year, CentOS7.6 version:
insert image description here
After purchasing, we can see the servers we all bought on the cloud server management and control platform . After purchasing the server, there will be a public IP and a private IP , which will be used later in the configuration.

insert image description here

Filing and Domain Name Resolution

Here to explain, because I purchased a Tencent Cloud domain name after purchasing the Alibaba Cloud server server, there were also some small problems in the middle. Generally speaking, everyone just needs to remember: record at the place where you purchased the server, and purchase the domain name. local domain name resolution .

Domain name filing

Go to Alibaba Cloud's official website , find the console, and click on the record in the upper right corner of the page to enter the record page. However, the record time is generally long, and it took me two or three days to successfully record. If you don't want to record, you can also directly access your own website through the public IP address of your server.(IP地址:端口号)

DNS

Alibaba Cloud: Enter the console, click the domain name in the pop-up column on the left, click Resolution to add a record, and follow the steps to resolve it.
Tencent Cloud: In the navigation bar on the right, register my domain name
insert image description here
, click Parse, and follow the steps:
insert image description here
After parsing the domain name, we can add some secondary domain names to it:
insert image description here

security strategy

Enter the Alibaba Cloud console , click the server you purchased, and enter the following page: Go
insert image description here
to Network and Security-Security Group->Configuration Rules:
Release some necessary ports: port 80, port 8080, port 888, port 8888, and you want to deploy the project yourself The port..., because I forgot to release port 80 at the beginning, I finally got stuck at the reverse proxy for a long time.
insert image description here

Install the pagoda panel

Enter the Pagoda official website www.bt.cn , click to install now:

insert image description here

To download the pagoda, you need to connect to the personal Ali server remotely:
insert image description here
here use the pagoda ssh client to connect remotely. If there is already a remote login software on the computer, you can not install it:
insert image description here
the connected IP address writes the public network ip of your own server, and then enter the root user name , and the remote login password set by your own server:
insert image description here
paste the installation command you just copied on the official website of the pagoda: here I use the CentOS installation command to
insert image description here
download and complete: the following content must be copied and saved first

insert image description here

Configure the pagoda panel

Enter: in the browser http://公网ip:8888/随机安全入口, enter the user name and password to log in, (that is, the content just saved)
insert image description here

Entering the home page pop-up window recommends you to install related software (click the recommended software in the left column to select the version and click the speedy installation to install) It takes a long time to install…

insert image description here

Pagoda panel:
insert image description here

Precautions:

Before installing the software, make sure that the system environment software such as Mysql and tomcat has not been installed in the Alibaba Cloud server before. If it is installed, it must be uninstalled and then install the recommended software of Pagoda. Otherwise, the installation will fail and the later stage will be relatively troublesome.

Server security group: 8888 release, 888 release, and Alibaba Cloud Server and Pagoda Security both need to release. If the deployed project cannot be accessed, first check whether the port is released.
insert image description here

Install other software

If you want to deploy a Java project, you must have a Java environment. When we install tomcat, the pagoda panel will automatically install a JDK for us and configure the environment. Tomcat7 installs jdk7 by default, and tomcat8 installs jdk8 by default. Here I installed the tomcat8 version. The other two software can simplify the deployment process of our project, and you can install it if you want to install it.

insert image description here

Database related

Enter the treasure panel, click database – root password to modify the password of the root user, generally modify it to a password that is commonly used in the configuration file in your project
insert image description here

Click to add database: the database name should be the same as the database name in your project, the user name and password are customized, but they need to be configured in the project

insert image description here

Project export and upload

Open your own project and modify the configuration file of the project as follows:

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver    
    url: jdbc:mysql://公网IP:3306/数据库名称?useSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8
    username: ly_myblog  # 服务器中设置的数据库用户名
    password: *********  # 设置的密码
 
logging:
  level:
    root: warn
    com.ly: info
  file:
    name: log/blog-pro.log

# 端口需要与站点的端口一致
server:
  port: 10080

Make sure that there is a configuration packaging method in the pom file, click Maven->Lifecycle in the right navigation bar, double-click clean, and then double-click package to package:
insert image description here
the package can be found in the corresponding directory:
insert image description here
enter the pagoda panel, upload the file, here I uploaded it to the www/wwwroot directory:
insert image description here
you can rename the jar package, just click Rename:
insert image description here

Deploy a website (simplified version)

Use Java project one-click deployment to quickly build a website:
insert image description here
double-click to open the Java one-click deployment panel: add a project, the port number is the same as the project's port number, and click OK.
insert image description here
After the creation is successful, click the mapping website to complete the deployment: (After clicking the mapping, the server will add the corresponding site, and the reverse proxy has been configured, which can be accessed directly through the domain name) Access
insert image description here
through the domain name on the browser:
insert image description here

Deploy the website (regular process)

Run the project:java -jar 文件名.jar

  • First make a remote connection to the Alibaba Cloud server
  • Switch to the corresponding folder:cd /www/wwwroot
  • Excuting an orderjava -jar 包名字.jar
  • Browser access website:域名 : 端口(或者公网IP:端口)进行访问

insert image description here

There is a built-in tomcat in the SpringBoot project, we can start it directly through java -jar, but this startup method will be closed once the console is closed, or crtl+c exits, we need another way:

Run forever: nohup java -jar XXX.jar >system.log 2>&1&, after running the command, the program will run forever and output the log

End the process: first use the ps -ef|grep javacommand to find the corresponding process number, and then kill -9 进程号kill the process

New site: Click on the website to create a new site
insert image description here

If the input has been parsed 域名(或公网IP):端口, you can also add no port, because the browser uses port 80 by default. Since the database has just been created, we don't need to create it here, and the default configuration can be used for everything else.
insert image description here
Site creation is complete:
insert image description here

Add reverse proxy configuration:

Click Reverse Proxy, click Add Reverse Proxy
insert image description here

Make relevant settings. The target URL is just tested. After submitting the URL of the website that can be accessed on the browser,
insert image description here
you can directly access the website through the domain name:
insert image description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324197300&siteId=291194637