0x00 主要环境:
- cURL
- Docker、Docker-Compose
- GO
- NodeJS、NPM
- Fabric
0x01 安装cURL
sudo apt install curl
0x02 安装Docker
1 准备工作
#更改系统软件源为国内源(/etc/apt/source.list)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#主要配置
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
//允许apt使用基于https的仓库安装软件
sudo apt-get install \
apt-transport-https \
ca-certificates \
software-properties-common
//添加docker阿里云GPG密钥(从docker官方下载的话比较慢)
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
//验证密钥是否添加成功
sudo apt-key fingerprint 0EBFCD88
//写入docker stable版本的阿里云镜像软件源
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
2 安装测试
sudo apt-get install docker-ce
//为当前用户添加操作权限
sudo usermod -aG docker XXX (XXX为当前用户名)
sudo chmod -R 777 /var/run/docker.sock
docker version
//或者
docker run hello-world
3 番外
#在后期的下载镜像中可以到阿里云配置自己的镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["阿里云镜像加速地址"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
0x03 安装Docker-Compose
sudo apt-get install python-pip
sudo pip install docker-compose
docker-compose version
0x04 安装GO
1 下载解压,移动至/usr/local下
wget https://studygolang.com/dl/golang/go1.12.5.linux-amd64.tar.gz
tar -xzf go1.12.5.linux-amd64.tar.gz
sudo mv go /usr/local
2 环境变量配置
sudo vim /etc/profile
//在文件尾部加上
export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
//保存退出
//使环境变量生效
source /etc/profile
//测试
go version
3 番外
#环境变量配置文件:
/etc/profile
/etc/environment
~/.profile
/etc/bashrc
~/.bashrc
0x05 安装NodeJS和NPM
#该过程安装最新版的NodeJS,自带NPM
sudo apt-get install -y nodejs
nodejs -v
0x06 安装Fabric
1 安装最新版
$ cd ~
$ curl -sSL http://bit.ly/2ysbOFE | bash -s
sudo vi /etc/profile
export PATH=$PATH:$HOME/fabric-samples/bin
2 测试
cd ~/fabric-samples/first-network/
./byfn.sh generate //生成证书和区块
./byfn.sh up //启动网络,模拟提议背书
./byfn.sh down //停止网络