【区块链】kali linux配置以太坊(geth)环境

如何使用kali linux配置以太坊环境呢?

【实验工具】
git-2.21.0(版本随意,kali自带)
node-12.18.4,npm-6.14.6(也可以下载其他版本)
go-1.9.2(使用go-1.9.2必须先有go-1.4)
geth-1.8.27(目前建议使用此版本)

安装指定版本git

1.下载v2.21.0版本
wget https://github.com/git/git/archive/v2.21.0.tar.gz
2.解压
tar -zxvf v2.21.0.tar.gz
3.进入解压目录
cd git-2.21.0/
4.编译
make prefix=/usr/local/git all
5.安装Git在/usr/local/git路径
make prefix=/usr/local/git install
6.配置环境变量
# 编辑环境配置文件
vi /etc/profile
# 末尾添加
export PATH=/usr/local/git/bin:$PATH
# 立马生效
source /etc/profile
7.测试
git version

安装nodejs和npm

1.使用wget命令下载压缩包
wget https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz
2.解压缩
tar -xvf node-v12.18.4-linux-x64.tar.xz
3.改名字为nodejs
mv node-v12.18.4-linux-x64 nodejs
4.将其移动到默认放软件的目录,便于管理(可以不做!!!)
mv nodejs/ /usr/local/sbin/
5.建立软连接,配置全局环境变量
sudo ln -s /usr/local/sbin/nodejs/bin/node /usr/local/bin/
sudo ln -s /usr/local/sbin/nodejs/bin/npm /usr/local/bin/
6.测试
root@simp:/usr/local/sbin# node -v
v12.18.4
root@simp:/usr/local/sbin# npm -v
6.14.6

安装go

一、克隆go仓库(https://github.com/golang/go.git),然后checkout到1.4分支,并安装该版本
[root@localhost software]# git clone https://github.com/golang/go.git
Cloning into 'go'...
remote: Counting objects: 322777, done.
remote: Compressing objects: 100% (73/73), done.
remote: Total 322777 (delta 32), reused 54 (delta 28), pack-reused 322675
Receiving objects: 100% (322777/322777), 147.71 MiB | 3.49 MiB/s, done.
Resolving deltas: 100% (255582/255582), done.
[root@localhost software]# cd go
[root@localhost go]# git branch
* master
[root@localhost go]# git checkout release-branch.go1.4
Branch release-branch.go1.4 set up to track remote branch release-branch.go1.4 from origin.
Switched to a new branch 'release-branch.go1.4'
[root@localhost go]# git branch
  master
* release-branch.go1.4
二、运行./all.bash安装脚本,必须等待成功
[root@localhost go]# cd src/
[root@localhost src]# ls
all.bash          archive  clean.bash  compress   debug     flag  html      io       log        make.rc        net        race.bat  run.bat  strconv    syscall  unicode
all.bat           bufio    clean.bat   container  encoding  fmt   image     lib9     make.bash  math           os         reflect   run.rc   strings    testing  unsafe
all.rc            builtin  clean.rc    crypto     errors    go    index     libbio   make.bat   mime           path       regexp    runtime  sudo.bash  text
androidtest.bash  bytes    cmd         database   expvar    hash  internal  liblink  Make.dist  nacltest.bash  race.bash  run.bash  sort     sync       time
[root@localhost src]# ./all.bash 
# Building C bootstrap tool.
cmd/dist

# Building compilers and Go bootstrap tool for host, linux/amd64.
lib9
libbio
liblink
cmd/cc
cmd/gc
cmd/6l

....

# Checking API compatibility.
Skipping cmd/api checks

real	0m0.538s
user	0m0.310s
sys	0m0.191s

ALL TESTS PASSED

---
Installed Go for linux/amd64 in /root/software/go
Installed commands in /root/software/go/bin
*** You need to add /root/software/go/bin to your PATH.
三、将安装好的go项目复制一份到/root/go1.4(必须去做!!!)
[root@localhost go]# pwd
/root/software/go
[root@localhost go]# cp -R /root/software/go /root/go1.4  【这一步必须做!!!之后要用】
[root@localhost go]# ls /root/go1.4/
api  AUTHORS  bin  CONTRIBUTORS  doc  favicon.ico  include  lib  LICENSE  misc  PATENTS  pkg  README  robots.txt  src  test  VERSION
[root@localhost go]# /root/go1.4/bin/go version
go version go1.4-bootstrap-20170531 linux/amd64
[root@localhost software]# wget https://github.com/golang/go/archive/go1.9.2.tar.gz
[root@localhost software]# tar zxvf go1.9.2.tar.gz
[root@localhost software]# cd go-go1.9.2/
[root@localhost go-go1.9.2]# ls
api  AUTHORS  CONTRIBUTING.md  CONTRIBUTORS  doc  favicon.ico  lib  LICENSE  misc  PATENTS  README.md  robots.txt  src  test  VERSION
[root@localhost go-go1.9.2]# cd src/
[root@localhost src]# ./all.bash 
##### Building Go bootstrap tool.
cmd/dist

##### Building Go toolchain using /root/go1.4.
bootstrap/cmd/internal/dwarf
bootstrap/cmd/internal/objabi
bootstrap/cmd/internal/src
.....
ALL TESTS PASSED

---
Installed Go for linux/amd64 in /root/software/go-go1.9.2
Installed commands in /root/software/go-go1.9.2/bin
*** You need to add /root/software/go-go1.9.2/bin to your PATH.
一、配置环境变量
[root@localhost software]vi /etc/profile
写入以下代码:(根据实际情况调整)
export GOROOT=/root/software/go-go1.9.2
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
二、使环境变量生效
[root@localhost software]source /etc/profile
[root@localhost software]go version
go version go1.9.2 linux/amd64
三、也可以建立软连接,配置全局环境变量(根据实际情况调整)
[root@localhost software]ln -s /root/software/go-go1.9.2/bin/go /usr/local/bin/go
四、测试,测试结束最好重启系统
[root@localhost software]go version
go version go1.9.2 linux/amd64

安装geth(go-ethereum)

1.克隆源码到本地
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum/
2.切换到目标branch(目前建议选择release/1.8,release/1.9有点问题)
git checkout release/1.8
3.编译,必须保证顺利完成
make geth
4.配置环境变量(根据实际情况调整)
export PATH=$PATH:/home/env/go-ethereum/build/bin
5.也可以建立软连接,配置全局环境变量(根据实际情况调整)
ln -s /home/env/go-ethereum/build/bin/geth /usr/local/bin/geth
6.测试
root@simp:/home/env# geth version
WARN [01-09|22:36:20.520] Sanitizing cache to Go's GC limits provided=1024 updated=655
Geth
Version: 1.8.27-stable
Git Commit: 4bcc0a37ab70cb79b16893556cffdaad6974e7d8
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.2
Operating System: linux
GOPATH=
GOROOT=/home/env/go-1.9.2
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寂寞烟火~

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值