搭建Gitolite服务及使用git-daemon

Gitolite 是一个新量级的Git服务,特别适合个人用户在网上建立自己的Git仓库。本文将描述如何建立Gitolite服务并设置 git-daemon 监听

前置必要条件:

  • Linux 系统(本文描述中使用的是CentOS 7)

  • git(可以使用系统自带的也可以自己编译,本文描述中所提到的git是自己编译的)

  • git-daemon(可以使用系统自带的也可以自己编译,本文描述中所提到的git-daemon是自己编译的)

  • open-ssh服务(CentOS已经默认安装、如果是Ubuntu则需要安装opensshd服务)

因为在我的服务器上端口9418已经被占用,所以在本文中将对git-daemon另外设置端口

搭建过程:

# useradd git
# su git
$ cd ~
$ mkdir -p ~/.local/bin
$ cd .local
$ git clone https://github.com/sitaramc/gitolite.git
$ cd gitolite
$ ./install -to ~/.local/bin
$ cd ~
$ ssh-keygen

$ cp .ssh/id_rsa.pub git.pub
$ source ~/.bash_profile
$ gitolite setup -pk git.pub

$ exit
# vim /lib/systemd/system/git-daemon.service

[Unit]
Description=Start Git Daemon

[Service]
ExecStart=/usr/local/bin/git daemon --reuseaddr --base-path=/home/git/repositories --export-all --port=<你自定义的Port>

Restart=always
RestartSec=500ms

StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=git-daemon

User=git
Group=git

[Install]
WantedBy=multi-user.target

# systemctl daemon-reload
# service git-daemon start

# netstat -tnpla | grep <你自定义的Port>

安装完成。以下是测试:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值