Appearance
centos配置golang各种环境
安装nodejs
进入nodejs官网,下载二进制程序包 tar.xz,上传到centos服务器,由于我的服务联公网,直接下载即可
bash[root@VM-0-10-centos ~]# wget https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.xz --2022-01-17 21:46:13-- https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.xz Resolving nodejs.org (nodejs.org)... 104.20.22.46, 104.20.23.46, 2606:4700:10::6814:162e, ... Connecting to nodejs.org (nodejs.org)|104.20.22.46|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 21619524 (21M) [application/x-xz] Saving to: ‘node-v16.13.2-linux-x64.tar.xz’ 100%[==================================================================================================================================>] 21,619,524 2.62MB/s in 11s 2022-01-17 21:46:25 (1.90 MB/s) - ‘node-v16.13.2-linux-x64.tar.xz’ saved [21619524/21619524] [root@VM-0-10-centos ~]#
解压,并移动到
/usr/local/
目录下bash[root@VM-0-10-centos ~]# tar xvf node-v16.13.2-linux-x64.tar.xz ....... node-v16.13.2-linux-x64/include/node/openssl/archs/linux64-riscv64/no-asm/include/openssl/opensslconf.h node-v16.13.2-linux-x64/include/node/openssl/archs/linux64-riscv64/no-asm/include/progs.h node-v16.13.2-linux-x64/include/node/openssl/bn_conf.h node-v16.13.2-linux-x64/include/node/openssl/dso_conf.h node-v16.13.2-linux-x64/include/node/openssl/opensslconf.h node-v16.13.2-linux-x64/include/node/openssl/bn_conf_asm.h node-v16.13.2-linux-x64/include/node/openssl/bn_conf_no-asm.h node-v16.13.2-linux-x64/include/node/openssl/dso_conf_asm.h node-v16.13.2-linux-x64/include/node/openssl/dso_conf_no-asm.h node-v16.13.2-linux-x64/include/node/openssl/opensslconf_asm.h node-v16.13.2-linux-x64/include/node/openssl/opensslconf_no-asm.h node-v16.13.2-linux-x64/include/node/zconf.h node-v16.13.2-linux-x64/include/node/zlib.h node-v16.13.2-linux-x64/README.md node-v16.13.2-linux-x64/LICENSE node-v16.13.2-linux-x64/CHANGELOG.md [root@VM-0-10-centos ~]# ls node-v16.13.2-linux-x64 node-v16.13.2-linux-x64.tar.xz [root@VM-0-10-centos ~]# mv node-v16.13.2-linux-x64 /usr/local/node [root@VM-0-10-centos ~]# ll /usr/local/ total 52 drwxr-xr-x. 2 root root 4096 Aug 5 2020 bin drwxr-xr-x. 2 root root 4096 Apr 11 2018 etc drwxr-xr-x. 2 root root 4096 Apr 11 2018 games drwxr-xr-x. 2 root root 4096 Apr 11 2018 include drwxr-xr-x. 2 root root 4096 Apr 11 2018 lib drwxr-xr-x. 2 root root 4096 Apr 11 2018 lib64 drwxr-xr-x. 2 root root 4096 Apr 11 2018 libexec drwxr-xr-x 6 1001 1001 4096 Jan 11 05:27 node drwxr-xr-x 14 root root 4096 Jan 17 13:32 qcloud drwxr-xr-x 3 root root 4096 Jan 17 13:31 sa drwxr-xr-x. 2 root root 4096 Apr 11 2018 sbin drwxr-xr-x. 5 root root 4096 Mar 7 2019 share drwxr-xr-x. 2 root root 4096 Apr 11 2018 src [root@VM-0-10-centos ~]#
创建软连接
bash[root@VM-0-10-centos ~]# ln -s /usr/local/node/bin/npm /usr/local/bin/ [root@VM-0-10-centos ~]# ln -s /usr/local/node/bin/node /usr/local/bin/ [root@VM-0-10-centos ~]# ln -s /usr/local/node/bin/npx /usr/local/bin/ [root@VM-0-10-centos ~]# npm -v 8.1.2 [root@VM-0-10-centos ~]# node -v v16.13.2 [root@VM-0-10-centos ~]# npx -v 8.1.2 [root@VM-0-10-centos ~]#
无脑复制步骤:
bash
wget https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.xz
tar xvf node-v16.13.2-linux-x64.tar.xz
mv node-v16.13.2-linux-x64 /usr/local/node
ln -s /usr/local/node/bin/npm /usr/local/bin/
ln -s /usr/local/node/bin/node /usr/local/bin/
ln -s /usr/local/node/bin/npx /usr/local/bin/
安装git
直接安装,非最新版
bash[root@VM-0-10-centos ~]# yum -y install git [root@VM-0-10-centos ~]# git --version git version 1.8.3.1
安装最新版
bashyum remove git // 卸载系统自带的git yum install -y gcc-c++ curl-devel zlib-devel perl-ExtUtils-MakeMaker // 安装依赖包 wget https://github.com/git/git/archive/refs/tags/v2.34.1.tar.gz //不能下载35-rc1 tar -xf git-2.34.1.tar.gz cd git-2.34.1 make configure //测试环境,如果报错 /bin/sh: autoconf: command not found //使用yum安装autoconf即可 ./configure --prefix=/usr/local/git // --prefix 指定git安装路径 make all // 编译 make install // 安装 //添加环境变量 ln -s /usr/local/git/bin/git /usr/local/bin/ //软连接失效 vi /etc/profile export PATH=$PATH://usr/local/git/bin source /etc/profile
安装golang
无脑复制步骤:
bash
tar xvf go1.17.6.linux-amd64.tar.gz
mv go /usr/local/golang
ln -s /usr/local/golang/bin/go /usr/local/bin/
ln -s /usr/local/golang/bin/gofmt /usr/local/bin/
go env -w GOPROXY=https://goproxy.cn,direct
配置密钥登录
无脑复制步骤:
bash
ssh-keygen -t rsa
cat id_rsa.pub >authorized_keys
chmod 600 authorized_keys
vim /etc/ssh/sshd_config
#配置密钥
AuthorizedKeysFile .ssh/authorized_keys
#使用公钥
PubkeyAuthentication yes
#禁用密码登录
PasswordAuthentication no
systemctl restart sshd
vscode配置
ini
Host tencent
HostName <ip>
User <account>
IdentityFile "密钥文件路径"