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:
Here I have purchased an ESC server for 1 year, CentOS7.6 version:
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.
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 .
- Aliyun domain name registration: https://wanwang.aliyun.com/domain
- Tencent Cloud Domain Name Registration: https://cloud.tencent.com/act/domainsales
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
, click Parse, and follow the steps:
After parsing the domain name, we can add some secondary domain names to it:
security strategy
Enter the Alibaba Cloud console , click the server you purchased, and enter the following page: Go
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.
Install the pagoda panel
Enter the Pagoda official website www.bt.cn , click to install now:
To download the pagoda, you need to connect to the personal Ali server remotely:
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:
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:
paste the installation command you just copied on the official website of the pagoda: here I use the CentOS installation command to
download and complete: the following content must be copied and saved first
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)
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…
Pagoda panel:
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.
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.
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
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
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:
the package can be found in the corresponding directory:
enter the pagoda panel, upload the file, here I uploaded it to the www/wwwroot directory:
you can rename the jar package, just click Rename:
Deploy a website (simplified version)
Use Java project one-click deployment to quickly build a website:
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.
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
through the domain name on the browser:
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 order
java -jar 包名字.jar
- Browser access website:
域名 : 端口(或者公网IP:端口)进行访问
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 java
command to find the corresponding process number, and then kill -9 进程号
kill the process
New site: Click on the website to create a new site
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.
Site creation is complete:
Add reverse proxy configuration:
Click Reverse Proxy, click Add Reverse Proxy
Make relevant settings. The target URL is just tested. After submitting the URL of the website that can be accessed on the browser,
you can directly access the website through the domain name: