http://blog.youkuaiyun.com/hacky_way/article/details/9191715
0.定义
1.安装git
- [test@localhost ~]$ sudo yum install git
- [test@localhost ~]$ git --version
- git version 1.7.1
2.为git服务器创建专有用户
- [test@localhost ~]$ sudo useradd git -d /home/git
- [test@localhost ~]$ su - git
3.安装gitolite
- [test@localhost ~]$ sudo yum install ssh
- [test@localhost ~]$ sudo service sshd start
- [test@localhost ~]$ sudo chkconfig sshd on
- [user@ubuntu ~]$ ssh-keygen -f ~/.ssh/admin
- [git@localhost ~]$ git clone git://github.com/sitaramc/gitolite
- [git@localhost ~]$ mkdir -p ~/bin
- [git@localhost ~]$ gitolite/install -to ~/bin
- [git@localhost ~]$ gitolite setup -pk admin.pub
如果在执行第三条命令时出现错误:
Can't locate Time/HiRes.pm in @INC (@INC contains: /home/git/gitolite/src/lib /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at /home/git/gitolite/src/lib/Gitolite/Common.pm line 76.
BEGIN failed--compilation aborted at /home/git/gitolite/src/lib/Gitolite/Common.pm line 76.
Compilation failed in require at gitolite/install line 15.
BEGIN failed--compilation aborted at gitolite/install line 15.
说明缺少perl需要的软件Time::HiRes,安装该软件包后,重新执行上面的命令:
- [test@localhost ~]$ sudo yum install perl-Time-HiRes
4.添加用户
- [user@ubuntu ~]$ git clone git@the_git_host:gitolite-admin
- repo foo
- RW+ = jason
- R = @all
- [user@ubuntu ~]$ git add conf
- [user@ubuntu ~]$ git add keydir
- [user@ubuntu ~]$ git commit -m 'added foo, gave access to jason'
- [user@ubuntu ~]$ git push
5.用户执行git版本管理
- [jason@linux ~]$ git clone git@the_git_host:foo
- [jason@linux ~]$ ssh git@the_git_host info
- [git@localhost ~]$ ls -a | grep gitolite | xargs rm -fr
- [git@localhost ~]$ rm -fr ~/repositories ~/bin ~/projects.list ~/.ssh/authorized_keys
6.配置gitweb
- [test@localhost ~]$ sudo yum install gitweb
- our $projectroot = "/home/git/repositories";
- our @git_base_url_list = qw(git://git.the_git_host
- ssh://git.the_git_host/var/lib/git);
- <VirtualHost *:80>
- ServerName the_git_host
- DocumentRoot /var/www/git
- <Directory /var/www/git>
- Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
- AllowOverride All
- order allow,deny
- Allow from all
- AddHandler cgi-script cgi
- DirectoryIndex gitweb.cgi
- </Directory>
- </VirtualHost>
- [test@localhost ~]$ sudo chmod 775 /home/git/repositories
- [test@localhost ~]$ sudo chmod 775 /home/git
- [test@localhost ~]$ sudo apachectl restart
注:如果在完成上述操作后,仍然显示404 no project found,那很可能又是SELinux惹的麻烦,尝试更改selinux的状态为permissive后再刷新页面试试:
- [test@localhost ~]$ sudo setenforce 0