搭建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. vim:将<esc>映射为CapsLock键

    无语,大写锁定键基本不用,却占据这么重要的位置,凭啥?换了,搜了半天,决定用它uncap(https://github.com/susam/uncap) 一个开放源代码的小工具,就位踢走大写键而生地, ...

  2. 使用vim-latex排版

    前几天在某个群上看到了一篇简历,内容不重要,一看排版很漂亮的说.一问才知道是用latex排版工具排版的.一想到我都大三下学期的,也快大四了,是不是要准备一份简历.于是就想使用latex这个排版工具来排 ...

  3. MySQL PLSQL Demo - 001.创建、调用、删除过程

    drop procedure if exists p_hello_world; create procedure p_hello_world() begin select sysdate(); end ...

  4. Spark学习笔记总结-超级经典总结

    Spark简介 spark 可以很容易和yarn结合,直接调用HDFS.Hbase上面的数据,和hadoop结合.配置很容易. spark发展迅猛,框架比hadoop更加灵活实用.减少了延时处理,提高 ...

  5. Ubuntu和Busybox下用make menuconfig配置出错解决

    http://blog.csdn.net/satiling/article/details/6965985 # make menuconfig In file included from script ...

  6. encoding/path可能引起无数奇怪的问题

    例如如下代码: <%@ page language="java" contentType="text/html; charset=UTF-8" pageE ...

  7. web-project的/WEB-INF/lib

    哪些jar包应该放到你的/WEB-INF/lib中?(目前为止,我的classpath只配置了dt.jar和tools.jar,也就是说,我的web-project所用的所有jar包都没有配置到cla ...

  8. 通过Windows PowerShell远程管理计算机(精简版)

    现在你手中有一台server(主控端),你打算通过主控端远程管理多台server(被控端).这个过程可以通过Windows PowerShell来完成. 首先在被控端上以管理员权限打开PowerShe ...

  9. ios的一些经验记录1

    1.UITextAlignment  ---> NSTextAlignment 2.找不到segue viewcontroller 与segue要对应 3.标题栏用NavigationContr ...

  10. C语言 · 回形取数

    基础练习 回形取数   时间限制:1.0s   内存限制:512.0MB        问题描述 回形取数就是沿矩阵的边取数,若当前方向上无数可取或已经取过,则左转90度.一开始位于矩阵左上角,方向向 ...