搭建Git服务器需要准备一台运行Linux的机器,本文以Centos6.8纯净版系统为例搭建自己的Git服务。

准备工作:以root用户登陆自己的Linux服务器。

第一步安装依赖库

[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@localhost ~]# yum install gcc perl-ExtUtils-MakeMaker

第二步卸载旧版git

加入原先有用yum安装过git,则需要先卸载一下

[root@localhost ~]# yum remove git

第三步下载源码

下载git-2.10.0.tar.gz 到 /usr/local/src

(查找git版本可以到https://www.kernel.org/pub/software/scm/git/下查看git的版本号自行选择下载)

查看版本方法:

[root@iZbp1ap7v4yegqdgzrh7cuZ ~]# wget -v https://www.kernel.org/pub/software/scm/git/

[root@iZbp1ap7v4yegqdgzrh7cuZ ~]# vi index.html

复制想下载的版本 --> Esc --> :q! -->  回车!

这里我选择下载git-2.10.0.tar.gz

[root@localhost ~]# cd /usr/local/src
[root@localhost ~]# wget https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz

第四步解压、编译和安装

[root@localhost ~]# tar -zvxf git-2.10.0.tar.gz
[root@localhost ~]# cd git-2.10.0
[root@localhost ~]# make prefix=/usr/local/git all
[root@localhost ~]# make prefix=/usr/local/git install

第五步将git目录加入PATH

[root@localhost ~]# echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
[root@localhost ~]# source /etc/bashrc

安装成功后就可以查看到git版本了。

[root@localhost ~]# git --version
git version 2.10.0

第六步创建git账号并设置密码

[root@localhost ~]# useradd -m git
[root@localhost ~]# passwd git
Changing password for user git.
New password:
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

第七步创建git仓库并初始化

[root@localhost ~]# mkdir -p /home/git/repositories/test.git
[root@localhost ~]# cd /home/git/repositories/test.git
[root@localhost test.git]# git --bare init
Initialized empty Git repository in /home/git/repositories/test.git/

第八步给git仓库目录设置用户和用户组并设置权限

[root@localhost test.git]# chown -R git:git /home/git/repositories
[root@localhost test.git]# chmod 755 /home/git/repositories

第九步限制git账号的ssh连接

查找git-shell所在目录

[root@localhost ~]# whereis git-shell
git-shell: /usr/src/git-2.10.0/git-shell

编辑passwd文件

[root@localhost ~]# vi /etc/passwd

找到这一行

git:x:500:500::/home/git:/bin/bash
将最后的/bin/bash改为:git-shell的目录 /usr/src/git-2.10.0/git-shell  如下:

git:x:500:500::/home/git:/usr/src/git-2.10.0/git-shell

Esc --> :wq! -->  回车!
完成搭建,去克隆提交试试吧!

clone地址:

ssh://git@服务器ip地址:端口/home/git/repositories/test.git

附加:以后每次新建仓库时,只需执行上面第七、八步即可!

Centos6.8搭建Git服务(git版本可选)的更多相关文章

  1. Centos6.9 搭建rsync服务端与客户端 案例:全网备份项目

    rsync的企业工作场景说明 1)定时备份 1.1生产场景集群架构服务器备份方案项目 借助cron+rsync把所有客户服务器数据同步到备份服务器 2)实时复制 本地数据传输模式(local-only ...

  2. centos6.4搭建lnmp服务(转载)

    1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 8 ...

  3. 一文详解CentOS6.5搭建DNS服务

    本文详细介绍DNS服务在Linux Operation System 中的搭建过程 一.DNS服务器的工作原理 客户机提出域名解析请求,并将该请求发送给本地的域名服务器.当本地的域名服务器收到请求后, ...

  4. Centos6.5搭建dhcpd服务

    dhcpd动态获取ip地址,对于小型局域网很便利的.在不大的网络社会静态ip也是不错的! 环境 centos6.5  10.10.24.1 (dns-server)   winxp sp3 (clie ...

  5. centos6.7搭建DHCP服务器

    centos6.7搭建DHCP服务 2017-03-24 09:47:16 系统环境: centos6.7 安装之前首先使用rpm –qa | grep dhcp查看系统中是否已安装了dhcp软件包. ...

  6. Centos6.8/7.0搭建Git服务http访问方式

    安装Git版本:git 2.10.0 Git访问方式:基于http的基本验证(非SSL) 1. 安装Apache软件: [root@localhost ~]# yum install httpd 设置 ...

  7. Git服务搭建及github使用教程

    .pos { position: fixed; top: 35%; left: 90% } .pos a { border: 2px solid white; background: #99CCFF; ...

  8. centos上搭建git服务--2

    在 Linux 下搭建 Git 服务器   环境: 服务器 CentOS6.6 + git(version 1.7.1)客户端 Windows10 + git(version 2.8.4.window ...

  9. 基于Gitea搭建属于自己的Git服务

    作者:IT王小二 博客:https://itwxe.com 一.搭建环境和前提 搭建环境: 操作系统:CentOS7.6 Docker版本:docker-ce-18.09.9 Lsky Pro版本:1 ...

随机推荐

  1. Extjs DateTime 日期时间选择控件 (非点击日期强制选择) 支持4.0以上

    Extjs的日期控件,仅仅能支持到日期选择,对时间的选择并不完好.而网上下载的控件,都是基于Ext.form.dateField 开发.在选中日期后自己主动选择,并隐藏此选择窗体. 在经过一番改造后, ...

  2. [Jobdu] 题目1500:出操队形

    题目描述: 在读高中的时候,每天早上学校都要组织全校的师生进行跑步来锻炼身体,每当出操令吹响时,大家就开始往楼下跑了,然后身高矮的排在队伍的前面,身高较高的就要排在队尾.突然,有一天出操负责人想了一个 ...

  3. LINUX下添加磁盘空间的方法详解

    给Linux系统添加磁盘空间在工作会经常遇到. 在添加第二块磁盘一般系统默认为hdb(IDE硬盘)sdb(SCSI 硬盘),以hdb为例. linux-isep:~ # fdisk /dev/hdb ...

  4. Effective JavaScript Item 33 让构造函数不再依赖newkeyword

    本系列作为EffectiveJavaScript的读书笔记. 在将function当做构造函数使用时,须要确保该函数是通过newkeyword进行调用的. function User(name, pa ...

  5. SDL2中文教程

    SDL2.0 Tutorial Index 原文地址:SDL 2.0 Tutorial Index Welcome! 下面的教程旨在为你提供一个SDL2.0以及c++中游戏设计和相关概念的介绍.在本教 ...

  6. 快速写excel的方法

    对于用com组件写excel,笔者表示那个太慢了.而且很耗资源,还要装excel. 今天我们就用写文本文件的方式来写excel. 步骤1,用excel写好一个设计一个我们想要的模板. 步骤2,我们把做 ...

  7. 利用对象思想来绘制canvas帧动画

    绘制思路: 1.封装一个对象出来: 2.属性: width . height imgSr speed dir3.行为: render changeDir html文件: <script> ...

  8. Linux中查看CPU信息【转】

    [转自]:http://blog.chinaunix.net/uid-23622436-id-3311579.html cat /proc/cpuinfo中的信息 processor       逻辑 ...

  9. display与visibility的区别

    style.visibility和style.display都可以实现对页的隐藏,但visibility要占用域的空间,而display则不占用 将元素display属性设为 block,会在该元素后 ...

  10. MFC和GTK的区别

    关键技术 http://blog.csdn.net/master_max/article/details/1540204 MFC和GTK的区别?? 1. 两者都是基于面向对象设计的.尽管MFC是用C+ ...