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
一、克隆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