关于centos7:centos-源码安装gitcentos环境变量的配置方法

3次阅读

共计 1531 个字符,预计需要花费 4 分钟才能阅读完成。

git 源码装置

1. 下载源码
wget https://github.com/git/git/archive/refs/tags/v2.31.0.tar.gz
2. 解压
tar -zxvf v2.31.0.tar.gz
3. 编译装置
cd vv2.31.0
.configure -prefix=/usr/lcoal/

报错: 提醒没有 .configure

解决: 装置 autoconf 生成

yum install autoconf
autoconf
.configure -prefix=/usr/local/

报错: no acceptable C compiler found in $PATH 没有 C 编译器

解决: 装置 C 编译器

yum install gcc
.configure -prefix=/usr/local/
make && make install

报错: fatal error: zlib.h: No such file or directory 没有 zlib.h

解决: 装置 zlib-devel

yum install zlib-devel
make && make install

呈现

 rm -f "$execdir/$p" && 
 if test -z ""; 
 then 
 test -n "" && 
 ln -s "$destdir_from_execdir_SQ/bin/git" "$execdir/$p" || 
 { test -z "" && 
 ln "$execdir/git" "$execdir/$p" 2>/dev/null || 
 ln -s "git" "$execdir/$p" 2>/dev/null || 
 cp "$execdir/git" "$execdir/$p" || exit; }; 
 fi 
done && 
remote_curl_aliases="" && 
for p in $remote_curl_aliases; do 
 rm -f "$execdir/$p" && 
 test -n "" && 
 ln -s "git-remote-http" "$execdir/$p" || 
 { test -z "" && 
 ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || 
 ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || 
 cp "$execdir/git-remote-http" "$execdir/$p" || exit; } 
done && 
./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
​

大略这么一串, 阐明胜利,cd 到装置门路

cd bin 
./git

当初阐明装置胜利, 然而还不能在别处运行, 咱们增加环境变量

4. 配置环境变量

永恒配置环境变量有两种办法, 一种是间接编辑 /etc/profile

vim /etc/profile

而后在最初追加

export PATH=$PATH:/usr/lcoal/soft/git/bin

间接编辑 profile 文件是不好保护的, 我采纳了另外一种办法

cd /etc/profile.d
vim git.sh

咱们在 profile.d 下新建一个脚本,profile 配置文件中会读取这个文件夹下所有的 sh, 新建内容:

export GIT_HOME=/usr/local/soft/git
export PATH=$PATH:$GIT_HOME/bin

而后

source /etc/profile

失效, 咱们测试一次写入的环境变量

echo $GIT_HOME
/usr/local/soft/git

环境变量失效, 当初测试 git

git version
git version 2.31.0

git 装置胜利, 尽管 yum install git 能够间接装置, 然而版本太老, 对 centos 感兴趣的倡议源码装置, 从中遇到问题, 解决问题, 能够学到很多的.

正文完
 0