Redhat 4搭建git服务器

Redhat 4说实话真心是太老了,可是没办法,给的环境就是这个,所以接受折磨吧,

这里把整个过程记录下来,留待后用。

1 安装yum

机器上没有一个软件包管理器着实蛋疼,所以首先是将这个搞定,下面是步骤

wget http://yum.baseurl.org/download/2.0/yum-2.0.8-1.src.rpm
rpmbuild --rebuild yum-2.0.8-1.src.rpm
cd /usr/src/redhat/RPMS/noarch/
rpm -ivh yum-2.0.8-1.noarch.rpm

然后是编辑相关的配置文件

vi /etc/yum.conf

[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
[base]
name=Red Hat Linux $releasever - $basearch - Base
baseurl=http://vault.centos.org/4.6/os/i386/


[updates]
name=Red Hat Linux $releasever - Updates
baseurl=http://vault.centos.org/4.6/updates/i386/

vi /etc/yum.repos.d/CentOS-Base.repo

#CentOS-Base.repo
#
# CentOS-4 is past End of Life ... use at your own risk
#

[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/4.9/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4

#released updates 
[update]
name=CentOS-$releasever - Updates 
baseurl=http://vault.centos.org/4.9/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=http://vault.centos.org/4.9/addons/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/4.9/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://vault.centos.org/4.9/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=http://vault.centos.org/4.9/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4

由于默认的源都不能用了,所以都改成了vault.centos.org的源,当然如果版本稍微高点,可以

选用中科大的源:centos.ustc.edu.cn

最后一步,update

yum update


2 搭建git服务器

首先是安装git所需的一些依赖包

yum install curl
yum install curl-devel
yum install zlib-devel
yum install openssl-devel
yum install perl
yum install expat-devel
yum install gettext-devely

接着去下载git的源码

wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz

源码有了,就可以进行编译安装了

tar zvxf git-latest.tar.gz 
cd git-2013-03-29/(这个版本可能和我不一样,看下载的时间)
autoconf
./configure 
make
make install
git -version
如果有了下面的显示,那么恭喜你,git搭建好了

git version 1.8.2.GIT

这时还需要做一件事,就是配置环境变量

在.bashrc和.bash_profile中添加一句

export PATH=/home/svn/git-2013-03-29:$PATH(其中路径为下载的git源码路径,因为安装到了那个目录下)

3 配置git服务器

这个我就不罗嗦了,直接上步骤吧,跟着来就可以了

[root@localhost git]# mkdir test
[root@localhost git]# git init --bare test
Initialized empty Git repository in /home/git/test/
[root@localhost git]# cd test/
[root@localhost test]# mkdir initial
[root@localhost test]# cd initial/
[root@localhost initial]# git init
Initialized empty Git repository in /home/git/test/initial/.git/
[root@localhost initial]# git remote add origin /home/git/test
[root@localhost initial]# touch Readme
[root@localhost initial]# git add Readme 
[root@localhost initial]# git commit -m "initial commit"
[master (root-commit) f067423] initial commit
 Committer: root <root@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Readme
[root@localhost initial]# git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To /home/git/test
 * [new branch]      master -> master

4 客户端clone

you@you:~$ git clone ssh://usr@ip:port/home/git/test testgit
Cloning into 'testgit'...
usr@ip's password: 
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

ok, 一切大功告成


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值