Recently, bloggers have taken on a wave of private work. Since the concept of going to the cloud has been deeply rooted in the hearts of the people, customers have asked bloggers to go to the cloud as well. This article will introduce the tutorials on going to the cloud.
1. How to choose a server
The blogger here recommends Alibaba Cloud Server. Alibaba Cloud ECS is a safe, reliable, elastic and scalable cloud computing service that helps you reduce IT costs, improve operation and maintenance efficiency, and enable you to focus more on core business innovation. Professional pre-sales technical support to help you choose the most suitable configuration plan
1.1 Product advantages
- Stable: 99.975% single-instance availability, 99.995% multi-zone multi-instance availability, 9 out of 9 cloud disk reliability, automatic migration and snapshot backup when downtime is available.
- Elasticity: Supports the creation of thousands of instances at the minute level. A variety of flexible payment options are more suitable for the current business situation. At the same time, it brings elastic expansion capabilities. Instances and bandwidth can be adjusted up and down at any time, and cloud disks can be expanded.
- Security: Provide services such as DDoS protection, Trojan horse killing, etc., and provide instances that support trusted computing, hardware encryption, and virtualized encrypted computing. It has passed multiple international security certifications, and ECS cloud disk supports data encryption.
- High performance: a single instance can choose up to 256vCPU, memory 6TB, main frequency 3.8GHz, performance up to 24 million PPS, 80Gbps, 1 million IOPS, 16 million sessions, network delay 20us+.
- Ease of use: Rich operating systems and application software can be easily deployed through one-click mirroring, and the same mirroring can quickly replicate the environment in multiple ECSs and expand easily.
- Scalability: ECS can seamlessly connect with various rich cloud products of Alibaba Cloud, and continuously provide complete computing, storage, security and other solutions for business development.
1.2 Existing offers
Now there are discounts for individuals and businesses. If you have a need, you can learn about it on the official website. The official website address:
click me click me
2. How to publish the backend project
Here, you need to install jdk, mysql, and redis three-piece set, and then you can directly start the jar package.
1. Install jdk
1. Download jdk8
Direct online disk link: https://pan.baidu.com/s/1Ip6ILZ5eU90aqNryUqwFgw
Extraction code: 8por
2. Import into linux
Here we install it in usr/local, which can be directly copied into it using ssh.
3. Unzip
cd /usr/local
tar -zxvf jdk-8u191-linux-x64.tar.gz
4. Environment variable configuration
vi /etc/profile
Press the i key to switch to edit mode. Find the end of the content, press the picture to enter the following paragraph. Type in front of unset i.
export JAVA_HOME=/usr/local/jdk1.8.0_231
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
#(!!!注意:JAVA_HOME的路径是你实际解压后的JDK的路径,千万别写错了)
Press Esc to exit edit mode, enter :wq to save and exit.
5. Environment variables take effect
source /etc/profile
6. Verify
java -version
If the version number is displayed, the installation is successful.
7. Other commands related to jdk
查看JDK版本:java -version
查看java执行路径:which java
查看JAVA_HOME路径:echo $JAVA_HOME
插卡PATH内容:echo $PATH
2. Install mysql database
1. Download
It is best not to download from the official website, it is relatively slow. Directly access the disk address.
Link: https://pan.baidu.com/s/1FNijjVILpp_96nbZrFQ-iQ
Extraction code: s59l
2. Unzip
Create a new folder and enter it to extract it.
tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
3. Move and rename
mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
4. Create mysql user groups and users and modify permissions
cd /user/local/mysql
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql #创建目录
chown mysql:mysql -R /data/mysql #赋予权限
5. Configure my.cnf
vim /etc/my.cnf
The configuration is as follows
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
lower_case_table_names=1
#大小写
6. Initialize the database
cd /usr/local/mysql/bin/
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
Note: Be sure to match the version of the system, the 32-bit installation package is 32-bit, and the Alibaba Cloud system defaults to 32-bit, otherwise an error will be reported. mysqld: mysqld: cannot execute binary file
7. View password
cat /data/mysql/mysql.err
It should be noted that the last one must be included. And if the mysql input password has no cursor, it can be copied and pasted directly.
8. Start mysql and change the root password
First place mysql.server in /etc/init.d/mysql.
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
start service
service mysql start
ps -ef|grep mysql
Out of service
service mysql stop
9. Change the password below
Log in to the initial password first, and copy the string you checked out above.
./mysql -u root -p
Landed successfully
10. Change password
SET PASSWORD = PASSWORD('123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
11. Change the configuration and use navicat to connect
use mysql #访问mysql库
update user set host = '%' where user = 'root'; #使root能再任何host访问
FLUSH PRIVILEGES;
If you do not want to use the mysql command in the bin directory every time, execute the following command
ln -s /usr/local/mysql/bin/mysql /usr/bin
3. Install redis
1. Download
Visit the official website and download it. It is relatively small. For the redis address, please visit: Redis official website .
Note: The c/c++ environment must be installed first! ! !
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
2. Unzip
Unzip the installation package, and a folder will be generated under the directory.
tar zxvf redis-5.0.7.tar.gz
3. compile
Then enter the unzipped folder to compile.
make
Remember, you must first install the c++ environment! !
4. Modify the configuration file redis.conf
There are mainly three parts to modify here. The following configuration needs to be commented/modified.
bind 0.0.0.0 #将改行注释
daemonize yes #将后台运行设为yes
protected-mode yes #将安全模式设为yes
requirepass 123456 #设置密码
5. run
cd src
./redis-server ../redis.conf
6. Verify
In order to start up, it can be used to see if it is started.
ps axu | grep redis
7. stop
./redis-cli shutdown
4. Start the jar package
Execute mvn clean install in the idea, and transfer the packaged jar package to the server through ssh, and execute nohup java-jar package name.
3. How to publish the front-end project
1. Install nginx
1. Install dependencies
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
2. Download
The nginx download address is as follows: just download it directly . Please select a newer version.
3. Copy into linux
Download nginx-1.21.4.tar.gz and move it to /usr/local/. You can use the ssh tool to copy directly.
4. Unzip
tar -zxvf nginx-1.21.4.tar.gz
5. compile
##进入nginx目录
cd nginx-1.21.4
## 配置
./configure --prefix=/usr/local/nginx-1.21.4
# make
make
make install
6. Verify
Test whether the installation is successful
./sbin/nginx -t
Abnormal
Cause Analysis: There is no logs folder in the nginx/ directory
Solution:
mkdir logs
chmod 777 logs
Successful installation.
7. Start nginx
cd /usr/local/nginx/sbin
./nginx //启动nginx
Successful
startup Configure nginx to start automatically at boot
vim /etc/rc.d/rc.local
2. Pack
Package to generate dist file.
yarn run build
Create a new jeecg-boot folder in nginx and put the generated dist folder into it.
3. Modify the configuration file
Modify the nginx configuration file as follows, file location:/usr/local/nginx-1.21.4/conf/nginx.conf
server {
listen 80;
server_name 你的域名;
#后台服务配置,配置了这个location便可以通过http://域名/jeecg-boot/xxxx 访问
location ^~ /jeecg-boot {
proxy_pass http://127.0.0.1:8080/jeecg-boot/;
proxy_set_header Host 127.0.0.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题
location / {
root html;
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html?s=$1 last;
break;
}
}
}
4. Verify
http://域名/jeecg-boot
Just visit
here, the springboot+vue project has been released successfully, do you want to experience it?