Install Golang1.16.3 on CentOS 7.8
首先,看看操作系统版本:
1 2 3 |
[root@mysql-pdc0023 ~]# cat /etc/redhat-release CentOS Linux release 7.8.2003 (Core) [root@mysql-pdc0023 ~]# |
将安装介质上传服务器:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@mysql-pdc0023 ~]# cd /tmp [root@mysql-pdc0023 tmp]# ls -ltr total 126008 drwx------ 3 root root 17 Mar 24 17:53 systemd-private-1c3e5dec3b63477a9a87436485355654-chronyd.service-AcdWYp drwxr-xr-x 2 redis redis 28 Mar 24 17:53 hsperfdata_redis drwx------ 3 root root 17 Mar 24 17:53 systemd-private-1c3e5dec3b63477a9a87436485355654-falcon-agentd.service-OMhwuy srwx------ 1 envuser envuser 0 Mar 24 17:53 mongodb-27017.sock -rw------- 1 root root 256 Apr 9 16:13 yum_save_tx.2021-04-09.16-13.IA5Uih.yumtx -rw------- 1 root root 256 Apr 9 16:14 yum_save_tx.2021-04-09.16-14.1sVTk7.yumtx -rw-r----- 1 supper-user supper-user 129021323 Apr 14 10:49 go1.16.3.linux-amd64.tar.gz [root@mysql-pdc0023 tmp]# [root@mysql-pdc0023 tmp]# du -sh go1.16.3.linux-amd64.tar.gz 124M go1.16.3.linux-amd64.tar.gz [root@mysql-pdc0023 tmp]# |
解压安装介质:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[root@mysql-pdc0023 tmp]# tar -xzf go1.16.3.linux-amd64.tar.gz [root@mysql-pdc0023 tmp]# [root@mysql-pdc0023 tmp]# ls -ltr | grep go srwx------ 1 envuser envuser 0 Mar 24 17:53 mongodb-27017.sock drwxr-xr-x 10 root root 272 Apr 2 01:39 go -rw-r----- 1 supper-user supper-user 129021323 Apr 14 10:49 go1.16.3.linux-amd64.tar.gz [root@mysql-pdc0023 tmp]# [root@mysql-pdc0023 tmp]# cd go/ [root@mysql-pdc0023 go]# ls -ltr total 216 -rw-r--r-- 1 root root 397 Apr 2 01:39 SECURITY.md -rw-r--r-- 1 root root 1480 Apr 2 01:39 README.md -rw-r--r-- 1 root root 1303 Apr 2 01:39 PATENTS -rw-r--r-- 1 root root 1479 Apr 2 01:39 LICENSE -rw-r--r-- 1 root root 101673 Apr 2 01:39 CONTRIBUTORS -rw-r--r-- 1 root root 1339 Apr 2 01:39 CONTRIBUTING.md -rw-r--r-- 1 root root 55669 Apr 2 01:39 AUTHORS -rw-r--r-- 1 root root 26 Apr 2 01:39 robots.txt drwxr-xr-x 3 root root 18 Apr 2 01:39 lib -rw-r--r-- 1 root root 5686 Apr 2 01:39 favicon.ico drwxr-xr-x 2 root root 80 Apr 2 01:39 doc drwxr-xr-x 2 root root 4096 Apr 2 01:39 api drwxr-xr-x 12 root root 165 Apr 2 01:39 misc drwxr-xr-x 23 root root 12288 Apr 2 01:39 test drwxr-xr-x 48 root root 4096 Apr 2 01:39 src -rw-r--r-- 1 root root 8 Apr 2 01:39 VERSION drwxr-xr-x 2 root root 29 Apr 2 01:41 bin drwxr-xr-x 6 root root 76 Apr 2 01:41 pkg [root@mysql-pdc0023 go]# |
解压后的文件中可以看到【bin】目录:
1 2 3 4 5 6 7 8 |
[root@mysql-pdc0023 go]# ls -ltr bin/ total 17108 -rwxr-xr-x 1 root root 3449719 Apr 2 01:41 gofmt -rwxr-xr-x 1 root root 14065061 Apr 2 01:41 go [root@mysql-pdc0023 go]# [root@mysql-pdc0023 go]# ./bin/go version go version go1.16.3 linux/amd64 [root@mysql-pdc0023 go]# |
移动到目标路径:
1 2 3 4 5 6 7 8 |
[root@mysql-pdc0023 go]# mkdir /opt/go [root@mysql-pdc0023 go]# cp -r * /opt/go [root@mysql-pdc0023 go]# [root@mysql-pdc0023 go]# ls -ltr /opt/go/bin/ total 17108 -rwxr-x--- 1 root root 14065061 Apr 14 11:14 go -rwxr-x--- 1 root root 3449719 Apr 14 11:14 gofmt [root@mysql-pdc0023 go]# |
配置环境变量:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[root@mysql-pdc0023 go]# vi ~/.bash_profile [root@mysql-pdc0023 go]# [root@mysql-pdc0023 go]# cat ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export ZK_HOME=/opt/software/zookeeper/apache-zookeeper-3.6.2-bin export GOROOT=/opt/go PATH=$GOROOT/bin:$PATH:$HOME/bin:$ZK_HOME/bin export PATH [root@mysql-pdc0023 go]# [root@mysql-pdc0023 go]# source ~/.bash_profile [root@mysql-pdc0023 go]# [root@mysql-pdc0023 go]# go version go version go1.16.3 linux/amd64 [root@mysql-pdc0023 go]# |
1 thought on “Install Golang1.16.3 on CentOS 7.8”