47

超级账本学习笔记1:环境搭建

 5 years ago
source link: https://studygolang.com/articles/19211?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

超级账本学习笔记1:环境搭建

开发环境

步骤1:安装Ubuntu虚拟机操作系统

首先在Windows系统上安装Virtual Box软件,从 https://www.virtualbox.org/ 地址下载并按照指示进行安装即可。然后,下载Ubuntu 18.04.2 LTS系统,从 https://www.ubuntu.com/download/desktop 地址下载。下载完成后,在Virtual Box新建一个虚拟机,然后将Ubuntu光盘镜像添加到虚拟机的存储中,接着,启动虚拟机,按照系统提示进行安装即可。

步骤2: 安装Docker

Docker是个开源的应用容器引擎,它让开发者可以打包应用以及依赖包到可移植的容器中,然后发布到任何Linux机器上。超级账本项目的开发也离不开Docker。

  1. 清除掉旧的Docker:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
  1. 更新apt包:
$ sudo apt-get update
  1. 安装一些依赖包,以允许apt可以通过HTTPS使用仓库repository:
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
  1. 添加Docker官方的GPG密钥,并验证:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88
  1. 设置稳定版本仓库:

注意下面的arch=amd64,表示当前的Linux系统的架构是amd64的,如果是不同的arch,那么需要修改对应的名称。

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  1. 开始安装Docker:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. 查看安装版本:
docker --version

步骤3:安装Git

Git是一个开源的分布式版本控制系统。几乎所有的超级账本项目都是开源项目,并托管在github上面,安装Git可以帮助我们高效地处理任何大大小小的项目。

  1. 安装Git:
$ sudo apt-get update
$ sudo apt-get install git
  1. 查看安装版本:
git --version
  1. 配置Git的用户名和邮箱:
$ git config --global user.name "输入你的用户名"
$ git config --global user.email "输入你的邮箱"

开发语言

超级账本项目的开发涉及到Golang、Node.js等语言。

步骤4:安装Go语言开发环境

  1. 更新apt包:
$ sudo apt-get update
$ sudo apt-get -y upgrade
  1. 下载Go语言包:

下面的链接可以在 https://golang.org/dl/ 上面查找到最新的稳定版本进行替换。

$ wget https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz
  1. 解压Go语言包并移动到/usr/local文件夹:
$ sudo tar -xvf go1.12.1.linux-amd64.tar.gz
$ sudo mv go /usr/local
  1. 添加环境变量:
$ export PATH=$PATH:/usr/local/go/bin
  1. 查看安装版本和参数配置:
$ go version
$ go env

步骤5:安装Node.js

  1. 安装Node.js:
$ curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
$ sudo apt-get install -y nodejs

如果curl在此之前没有安装的话,可以先运行下面的命令进行安装,再安装Node.js:

$ sodu apt-get install curl
  1. 查看安装版本:
$ node --version

以上,就是搭建超级账本项目的开发环境的整个过程。

参考

  1. Docker: https://docs.docker.com/install/linux/docker-ce/ubuntu/
  2. Git: https://www.atlassian.com/git/tutorials/install-git#linux
  3. Golang: https://golang.org/doc/install
  4. Node.js: https://github.com/nodesource/distributions/blob/master/README.md

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK