前后端分离式部署
JoBackRer Lv2

安装前可以先更新一下apt的包源

1
sudo apt-update

后端服务安装

Redis

安装前置

1
sudo apt install lsb-release curl gpg

安装redis

1
apt-get install redis-server

启动redis服务,设置开启启动,查看redis服务状态

1
2
3
sudo systemctl start redis-server
sudo systemctl enable redis-server
sudo systemctl status redis-server

配置redis

1
vim /etc/redis/redis.conf

配置文件详细:

1
2
3
bind 127.0.0.1 ::1 #redis绑定的ip地址
port 6379 #redis监听端口
daemonize yes #让redis在后台运行

RabbitMQ

安装,启动

1
2
3
sudo apt-get install rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl enable rabbitmq-server

然后启用rabbitmq的web管理页面

1
sudo rabbitmq-plugins enable rabbitmq_management

添加一个admin账户

1
2
3
4
sudo rabbitmqctl add_user admin admin
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
sudo rabbitmqctl set_user_tags admin administrator

重启rabbitmq服务应用更改

1
sudo systemctl restart rabbitmq-server

rabbitmq网址:http://localhost:15672

JDK

安装jdk17

1
2
3
4
sudo apt install software-properties-common
sudo add-apt-repository ppa:linuxuprising/java
sudo apt update
sudo apt install oracle-java17-installer

查找安装目录

1
readlink -f $(which java)

更新fisco到3.0版本

1
https://fisco-bcos-doc.readthedocs.io/zh-cn/latest/docs/quick_start/air_installation.html

前端服务安装

nodejs+npm+vue

使用apt安装nodejs和npm

1
2
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs

将npm的源设置为国内

1
2
3
npm config set registry http://registry.npm.taobao.org
#安装vue
npm install -g vue-cli

查看安装是否成功

1
2
3
node -v
npm -v
vue -V

解压front.zip文件,进入文件内输入

1
2
npm install #执行安装前置
npm run dev #启动前端

后端与前端启动

复制区块链的密钥

1
cp -r nodes/127.0.0.1/sdk/* ./config/conf

/config/conf用于存放密钥

编辑配置文件

1
vim ./config/application.yml
1
2
3
4
5
rabbitmq:
addresses: 127.0.0.1:5672 #改为本地ip
username: admin #账号
password: admin #密码
virtual-host: /

编辑链接区块链的连接配置文件

1
vim config/config-fisco.toml
1
2
3
4
[network]
messageTimeout = "10000"
defaultGroup = "group0"
peers=["127.0.0.1:20201"] # The peer list to connect

编写sh脚本

新建一个启动脚本文件:

pwd

1
touch start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

# jar文件路径
SERVER_JAR="/path/to/your/server.jar"

# 服务器的启动参数
STARTUP_PARAMETERS=""

# 检查服务器jar文件是否存在
if [ ! -f "$SERVER_JAR" ]; then
echo "Server jar not found at $SERVER_JAR"
exit 1
fi

# 使用java命令启动服务器
java -Xmx1024M -Xms1024M -jar $SERVER_JAR $STARTUP_PARAMETERS
1
bash start.sh #启动脚本
 Comments
Comment plugin failed to load
Loading comment plugin