Centos6.8搭建Git服务(git版本可选)
搭建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版本可选)的更多相关文章
- Centos6.9 搭建rsync服务端与客户端 案例:全网备份项目
rsync的企业工作场景说明 1)定时备份 1.1生产场景集群架构服务器备份方案项目 借助cron+rsync把所有客户服务器数据同步到备份服务器 2)实时复制 本地数据传输模式(local-only ...
- centos6.4搭建lnmp服务(转载)
1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 8 ...
- 一文详解CentOS6.5搭建DNS服务
本文详细介绍DNS服务在Linux Operation System 中的搭建过程 一.DNS服务器的工作原理 客户机提出域名解析请求,并将该请求发送给本地的域名服务器.当本地的域名服务器收到请求后, ...
- Centos6.5搭建dhcpd服务
dhcpd动态获取ip地址,对于小型局域网很便利的.在不大的网络社会静态ip也是不错的! 环境 centos6.5 10.10.24.1 (dns-server) winxp sp3 (clie ...
- centos6.7搭建DHCP服务器
centos6.7搭建DHCP服务 2017-03-24 09:47:16 系统环境: centos6.7 安装之前首先使用rpm –qa | grep dhcp查看系统中是否已安装了dhcp软件包. ...
- Centos6.8/7.0搭建Git服务http访问方式
安装Git版本:git 2.10.0 Git访问方式:基于http的基本验证(非SSL) 1. 安装Apache软件: [root@localhost ~]# yum install httpd 设置 ...
- Git服务搭建及github使用教程
.pos { position: fixed; top: 35%; left: 90% } .pos a { border: 2px solid white; background: #99CCFF; ...
- centos上搭建git服务--2
在 Linux 下搭建 Git 服务器 环境: 服务器 CentOS6.6 + git(version 1.7.1)客户端 Windows10 + git(version 2.8.4.window ...
- 基于Gitea搭建属于自己的Git服务
作者:IT王小二 博客:https://itwxe.com 一.搭建环境和前提 搭建环境: 操作系统:CentOS7.6 Docker版本:docker-ce-18.09.9 Lsky Pro版本:1 ...
随机推荐
- 【转】容易被忽略CSS特性
这里主要是为了留个备份,更好的排版请查看原文: http://www.cnblogs.com/dolphinX/p/3511300.html //以下为全文转载 CSS初学感觉很简单,但随着学习的深入 ...
- Android --------------------ActionBar 与 ViewPager 和 ActionTab 切换 的源代码实现
參考网址: 点击打开链接 源代码实现: package com.example.actionbardemo2; import android.app.ActionBar; import android ...
- wpf程序线程与UI内容交互
在UI线程里执行复杂的操作,会造成UI假死.常用的解决方法是开2个线程. 而新线程要调用UI里的东西,必须这么用: this.Dispatcher.Invoke(content);
- 在FPGA中使用for循环一定浪费资源吗?
渐渐地,发现自己已经习惯于发现细节,喜欢打破常规,真的非常喜欢这种feel. 相信很多人在书上或者博文上都有提出“在FPGA中使用for语句是很占用资源的”的观点,特权同学也不例外.那么,这种观点正确 ...
- 每日英语:New Reason To Get The Kids To Bed On Time
Going to bed at the same time every night could give your child's brain a boost, a recent study foun ...
- 从JDBC程序看为什么需要Mybatis
package com.xuebusi.jdbc; import java.sql.*; /** * 从JDBC程序看为什么需要Mybatis * * 1.加载驱动程序和数据库连接所需要的url.用户 ...
- linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题]
linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题] 一.查看mysql是否已经安装 使用“whereis mysql”命令来查看mysql安装路径: [root@h ...
- WSAAsyncSelect 模型
WSAAsyncSelect模型是winsock编程模型的一种,它提供了socket异步编程的方便,其实现是基于Windows消息机制的,最主要的就是下面这个函数: int PASCAL FAR WS ...
- Sql Server连接字符串
SQL Server .NET Data Provider 连接字符串包含一个由一些属性名/值对组成的集合.每一个属性/值对都由分号隔开. PropertyName1=Value1; ...
- php写杨辉三角算法
<?phpfunction YangHui($iLine) { for ($i = 0;$i <= $iLine;$i++)//行 { for ($j ...