Centos7 yum安装git服务器
安装git
yum install git
检查git版本
git –version
发现不是较新的版本或者是我们想要的版本
移除该版本git
yum remove git
下载编译工具
yum -y groupinstall Development Tools
下载依赖包
yum -y install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
下载 Git 最新版本的源代码
wget https://www.kernel.org/pub/software/scm/git/git-2.32.0.tar.gz
登录https://github.com/git/git/releases查看git的最新版。不要下载带有-rc的,因为它代表了一个候选发布版本。
https://github.com/git/git/archive/refs/tags/v2.32.0.tar.gz
解压
tar -zxvf git-2.9.5.tar.gz
进入目录配置
cd git-2.32.0./configure –prefix=/usr/local/git
安装
make && make install
配置全局路径
export PATH="/usr/local/git/bin:$PATH"source /etc/profile
以上即为安装的全部步骤。
后续使用中,遇到错误
Unable to find remote helper for ‘https’解决方法:将 /usr/libexec/git-core 纳入 PATH,至少在使用 git 之前,设置一下PATH
PATH=$PATH:/usr/libexec/git-core
或直接在 /etc/profile 中修改。
配置环境变量的备用方案:
[root@bogon git-2.3.0]# echo "export PATH=$PATH:/usr/local/git/bin" > /etc/profile.d/git.sh[root@bogon git-2.3.0]# source /etc/profile.d/git.sh[root@bogon git-2.3.0]# git --version
下面是补充
使用SSH搭建GIT服务器,要做以下准备工作:1、在服务器和客户端机器上分别安装git2、在服务器上安装ssh服务3、在客户端机器上安装SSH客户端
make clean 清除编译yum remove git 卸载
安装服务端:
(1)首先先更新系统
sudo yum update
(2)安装依赖的包
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
(3)下载git源码并解压缩
wget https://Github.com/Git/Git/archive/v2.32.0.tar.gztar zxvf v2.32.0.tar.gzcd git-2.32.0make prefix=/usr/local/git all
如果出现错误:
libgit.a(utf8.o): In function reencode_string_iconv': /root/git-2.3.0/utf8.c:463: undefined reference tolibiconv’ libgit.a(utf8.o): In function reencode_string_len': /root/git-2.3.0/utf8.c:502: undefined reference tolibiconv_open’ /root/git-2.32.0/utmake prefix=/usr/local/git install
安装libiconv
下载编译
cd /usr/localwget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztar -zxvf libiconv-1.14.tar.gzcd libiconv-1.14./configure –prefix=/usr/local/libiconv && make && make install
创建一个软链接到/usr/lib
ln -s /usr/local/lib/libiconv.so /usr/libln -s /usr/local/lib/libiconv.so.2 /usr/lib
然后回到git目录继续编译
make prefix=/usr/local/git allmake prefix=/usr/local/git install
**(5)此时你如果使用git --version 查看git版本的话,发现git仍然是1.8.1版本。这是因为它默认使用了"/usr/bin"下的git。**你可以用下面的命令查看git所在的路径:
$ whereis gitgit: /usr/bin/git /usr/local/git /usr/share/man/man1/git.1.gz
**(6)我们要把编译安装的git路径放到环境变量里,让它替换"/usr/bin"下的git。为此我们可以修改“/etc/profile”文件(或者/etc/bashrc文件)。**
sudo vim /etc/profile
然后在文件的最后一行,添加下面的内容,然后保存退出。
export PATH=/usr/local/git/bin:$PATH
**(8)然后再次使用git --version 查看git版本,发现输出2.3.0,表明安装成功。**
**安装gitosis:**
下载setuptools放到你想放的目录,我自己放在/usr/local/src这里
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-19.0.tar.gz#md5=b921200449c8b52d62c7e70a47956b69 (https://pypi.python.org/pypi/setuptools#downloads)这个网址下载的,可以去下载最新tar zxvf setuptools-19.0.tar.gzcd setuptools-19.0python setup.py installcd /usr/localgit clone git://github.com/res0nat0r/gitosis.gitcd gitosis
**python setup.py install 显示Finished processing dependencies for gitosis==0.2即表示成功**
**在Linux服务器上****第一步,先创建一个专门由于git仓库的一个账号吧,这样也方便进行管理 (如果已经有账号则不需要执行这步)**
sudo groupadd git #新建一个git用户组sudo useradd git -m -s /sbin/nologin -d /home/git -g git #新建一个git用户,创建目录,并禁止shell登录,添加到git用户组sudo useradd git -m -s /bin/bash -d /home/git -g git #新建一个git用户,创建目录,并允许shell登录,添加到git用户组
**第二步:新建一个git空仓库。**
切换到你用来管理git的账号,本人是git账号:su git 或者你用root
cd /home/git/mkdir www.laogao.com 项目文件夹,名字自定义cd www.laogao.comgit init –bare
显示:Initialized empty Git repository in /home/git/www.laogao.com.git/ 表示已经建立成功
**第三步:添加用户的公钥**1.切换到你操作git的用户,列如(su git)
mkdir /home/git/.sshchmod 700 .sshcd /home/git/.sshssh-keygen -t rsa //默认会生成~/.ssh/id_rsa.pub公钥文件。gitosis-init < /home/git/.ssh/id_rsa.pub //初始化
**初始化完出现3个文件****authorized_keys****id_rsa****id_rsa.pub**
最后:
chmod 600 authorized_keysvim authorized_keys“`
把你客户端生成的公钥复制进去即可。
栏 目:Redhat
本文标题:Centos7 yum安装git服务器
本文地址:http://www.ziyuanwuyou.com/html/caozuoxitong/Redhat/4742.html
您可能感兴趣的文章
- 12-21Redhat实战手册:Linux系统管理必备指南。
- 12-21从入门到精通:Redhat网络管理全攻略
- 12-21详解Redhat下的系统备份与恢复策略
- 12-21使用Redhat构建高性能的云计算环境
- 12-21零基础学习Redhat,轻松上手Linux系统管理
- 12-21Redhat Linux系统性能优化实战教程
- 12-21如何使用Redhat进行系统的安全设置与防护
- 12-21Redhat虚拟机配置与管理教程
- 12-21玩转Redhat命令行,提升工作效率的秘籍大公开
- 12-21探索Redhat下的系统监控与性能分析
阅读排行
推荐教程
- 12-13centos7怎么进去tmp目录并清除垃圾
- 12-21从新手到专家,Redhat带你走进Linux世界
- 12-13Centos和Redhat的区别与联系
- 12-13Centos 7 压缩与解压缩命令
- 12-21零基础也能学会Redhat系统维护与优化
- 12-21探索Redhat:Linux系统使用手册
- 12-21从入门到精通:Redhat Linux系统使用全程指南
- 12-13CentOS7默认的快捷键怎么修改设置
- 12-21如何使用Redhat进行系统的安全设置与防护
- 12-21Redhat虚拟机配置与管理教程