CentOS 6.3下使用Gitosis安装搭建Git Server教程

2020-01-30 13:42:58王冬梅

[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = git@node2.example.com
[group test]
writable = test
members = git@node2.example.com john
————————————————————————————————————
# git add .
# git commit -am "add member john and project foo"
# git push

3. 用户git添加项目test


复制代码
# su - git
# cd ~/projects
# mkdir test
# cd test
# git init
# echo "Hello World." > hello.txt
# git add hello.txt
# git commit -am 'first commit'
# git remote add origin git@node2.example.com:test.git
# git push origin master

4. 用户 john clone test并修改hello.txt

复制代码
# su - john
# git clone git@node2.example.com:test.git
# cd test
# date >> hello.txt
# git commit -am 'add time to hello.txt' && git push

整个过程分为:

1.通过修改gitosis-admin管理gitosis用户权限,需要clone到本地,然后修改配置文件,最后add push将结果推送到远程实现权限修改.

2.添加系统用户,生成该用户公钥,并将其复制到keydir下,实现该用户有权限进行git等相关操作.

3.登陆该用户账户进行git相关操作,修改完后commit,push到中服务器即可完成仓库权限配置.

七.安装gitweb

1.首先我们需要Git的源码,其中带有GitWeb,并能生成定制的CGI脚本:

复制代码
# git clone git://git.kernel.org/pub/scm/git/git.git
# cd git/
# make GITWEB_PROJECTROOT="/home/git/repositories" prefix=/usr gitweb
# cp -rf gitweb /usr/local/apache2/htdocs/

注: 通过指定 GITWEB_PROJECTROOT 变量告诉编译命令 Git 仓库的位置

2.设置Apache以CGI方式运行该脚本,并添加一个VirtualHost配置:

(1).加载apache的vhost配置文件

复制代码
# vi /usr/local/apache2/conf/httpd.conf

搜索包含httpd-vhosts的行,并去掉该行注释.
(2).加载cgid模块,使其支持perl语言.

复制代码
# vi /usr/local/apache2/conf/httpd.conf

搜索包含mod_cgid.so的行,并去掉该行注释.
(3).配置VirtualHost

复制代码
# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf

添加如下配置:

复制代码
——————————————————————————————————————————