参考文章:
[1] http://hokietux.net/blog/?p=58 [2] http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way [3] http://www.nkuttler.de/2009/04/06/git-clone-ssh-could-not-resolve-hostname/
- git
很简单,直接用pacman安装即可 sudo pacman -S git
- gitosis
gitosis是一个方便管理git仓库的工具,安装方法:
1) 从yaourt或者aur下载安装gitosis-git包 http://aur.archlinux.org/packages.php?ID=23419
2) 新建git用户 sudo useradd –system –shell /bin/sh –comment ‘git version control’–user-group –home-dir /home/git/ git
3) 将开发用户的rsa公钥导入gitosis,(没有公钥的话请先运行ssh-keygen -t rsa生成) sudo -H -u git gitosis-init < ~/.ssh/id_rsa.pub
4) 如果以上步骤没有问题,那么运行 git clone ssh://git@hostname/gitosis-admin.git 后应该就能看到gitosis-admin.git这个目录了
5) 新建项目、添加用户等操作参见[2],这里不再赘述
- gitweb
事实上ArchLinux中安装的git包自带了gitweb,可以用which gitweb搜到,一般默认在/usr/share/gitweb。下面假设我的http根目录为/home/httpd
1) 将/usr/share/gitweb下的文件复制到/home/httpd/cgi-bin(其实似乎只要gitweb.cgi就够了) sudo cp -R /usr/share/gitweb /home/httpd/cgi-bin/
2) /usr/share/gitweb下的.css和.png复制到/home/httpd/html/git/
3) 修改或创建/etc/gitweb.conf,具体配置如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
4) 在apache的配置中增加以下内容 /etc/httpd/conf/httpd.conf,这里我没有用VirtualHost机制,只加了行URL重写规则,VirtualHost的配置方法参见[1]
1 2 | |
5) 重启apache后应该就能访问 http://hostname/gitweb/ 了,如果提示Project not found,请确认apache能访问git的仓库目录,并且相应的项目目录下有git-daemon-export-ok这个文件。