当前位置: 首页 > 工具软件 > blockscout > 使用案例 >

Ubuntu部署 Blockscout 区块链浏览器流程

云新知
2023-12-01

Ubuntu部署 Blockscout 区块链浏览器流程

基础环境安装

Erlang 和 Elixir

# 安装最新的erlang包源,不执行这一步,无法安装最新版本的erlang
wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
sudo dpkg -i erlang-solutions_2.0_all.deb

# 安装
sudo apt update
sudo apt install erlang

# 验证安装结果
Erlang
# root@ip-127-0-0-1:/home/ubuntu# erl
# Erlang/OTP 24 [erts-12.3.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]
#
# Eshell V12.3.1  (abort with ^G)
# 1>    # 退出输入 contrl + g
#  User switch command
#  --> q	# 输入 q

Elixir 
# root@ip-172-31-16-35:/home/ubuntu# iex
# Erlang/OTP 24 [erts-12.3.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit]
#
# Interactive Elixir (1.13.0) - press Ctrl+C to exit (type h() ENTER for help)
# iex(1)>	# 退出输入 contrl + c
# BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
#       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
# a		# 输入 a

Nodejs

安装最新的LTS版本

nodejs 的每个大版本号都有相对应的源,比如这里的 16.x.x版本的源是https://deb.nodesource.com/setup_16.x

# 导入16.x.x的源
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install nodejs
# 验证安装结果
nodejs -v

Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 安装提示,选择1(默认为1)
# 1) Proceed with installation (default)
# 2) Customize installation
# 3) Cancel installation
1 # 直接回车也可
#
# 更新环境变量
source $HOME/.cargo/env
source ~/.profile

Libtool

sudo apt install libtool

Inotify-tools

 apt install inotify-tools

GCC Compiler

apt install gcc

make

sudo apt install make

AutoMake

sudo apt install automake

G++ Compiler

sudo apt install g++

GMP(gmp-devel)

wget https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2
# 解压
tar -xjvf gmp-6.2.1.tar.bz2
# 编译并安装
cd gmp-6.2.1
./configure
make 
make check 
sudo make install

数据库

Postgre Sql

sudo apt install postgresql

编译并部署Blockscout

拉取源码

git clone https://github.com/blockscout/blockscout.git
cd blockscout

安装Mix依赖,编译Blockscout

mix do deps.get
mix do local.rebar --force
mix do deps.compile
mix do compile

配置环境变量

export ETHEREUM_JSONRPC_VARIANT=geth
export COIN=DFAX
export COIN_NAME=DFAX
export PORT=14000	# 浏览器端口
export NETWORK=DFAX	
export SUBNETWORK=DFAX MAINNET
export ETHEREUM_JSONRPC_HTTP_URL=http://127.0.0.1:8545	# 链RPC endpoint
export ETHEREUM_JSONRPC_TRACE_URL=http://127.0.0.1:8545
export NETWORK_ICON=/home/ubuntu/ic_launcher_round.png
export LOGO=/home/ubuntu/ic_launcher_round.png
export DATABASE_URL=postgresql://postgres:<postgres password>@<postgresql endpoint>/blockscout?ssl=false
export DISABLE_EXCHANGE_RATES=true

数据库迁移

mix do ecto.drop, ecto.create, ecto.migrate

安装nodejs依赖

cd apps/block_scout_web/assets
npm install && node_modules/webpack/bin/webpack.js --mode production

cd ..
mix phx.digest

启用HTTPS

生成https证书

cd apps/block_scout_web/
mix phx.gen.cert blockscout blockscout.local

配置 host文件

vi /etc/hosts

# 追加一下内容
::1 localhost   localhost.localdomain   localhost6  localhost6.localdomain6     blockscout blockscout.local
localhost.localdomain   localhost4  localhost4.localdomain4     blockscout blockscout.local

启动Blockscout

切换到 blockscout 目录下执行

mix phx.server
 类似资料: