ServerMansVPSをGitサーバーにする

 

参考URL
CentOSのxinetdでGitサーバを立てる
gitosis - Git リポジトリ群の管理とアクセス制御 vol.1
git sshサーバの構築
How To: Install and Configure GitWeb

必要なRPMのインストール

インストール

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

yum install git --enablerepo=rpmforge
yum install git-daemon --enablerepo=rpmforge
yum install gitosis
yum install gitweb

git config --global user.name "git"
git config --global user.email ******

gitユーザー作成
#useradd git

一般ユーザー公開鍵作成
ssh-keygen -t rsa -C xxx@example.com

sudo コマンドが使用可能にする
#visudo
username ALL=(ALL) ALL 追記

gitosisの初期化
$sudo -H -u git gitosis-init < /home/username/.ssh/id_rsa.pub

ローカル(airmac)からclone
$git clone ssh://git@example.com:3843/gitosis-admin.git

xinet.d/gitを編集
service git
{
disable = yes
socket_type = stream
wait = no
user = nobody
server = /usr/bin/git-daemon
server_args = --base-path=/var/lib/git --export-all --user-path=public_git --syslog --inetd --verbose
log_on_failure += USERID
# xinetd does not enable IPv6 by default
flags = IPv6
}
--base-path=/home/git/repositories
user = git
--export-allを削除

macから
$git clone ssh://git@example.com:3843/home/git/repositories/gitosis-admin.git

SSHの設定でパスワードが設定されていたら優先されるそうですが後ほど対応。

windowsのgit gui
既存リポジトリを複製
ssh://git@example.com:3843/home/git/repositories/gitosis-admin.git

gitwebの設定
#yum install gitweb
でインストールされた場合、
/var/www/git
にファイルがある。

httpd.confを設定
ServerName git.example.net

SetEnv GITWEB_CONFIG /etc/gitweb.conf

Alias /static/gitweb.css /var/lib/gitweb/gitweb-theme/gitweb.css
Alias /static/gitweb.js /var/lib/gitweb/gitweb-theme/gitweb.js
Alias /static/git-logo.png /var/lib/gitweb/static/git-logo.png
Alias /static/git-favicon.png /var/lib/gitweb/static/git-favicon.png

ScriptAlias /cgi-bin /var/lib/gitweb

DocumentRoot /home/git/repositories

Options Indexes FollowSymlinks ExecCGI
AllowOverride None
#Order allow,deny
#Allow from all

AuthUserFile /home/git/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user
Order allow,deny
Allow from all

DirectoryIndex /cgi-bin/gitweb.cgi

RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^.* /cgi-bin/gitweb.cgi/$0 [L,PT]
RewriteRule ^[a-zA-Z0-9_\-]+\.git/?(\?.*)?$ /gitweb.cgi%{REQUEST_URI} [L,PT]

ErrorLog /home/git/logs/error_log
CustomLog /home/git/logs/access_log common

gitグループにapacheユーザを追加
usermod -G git apache

gitosis-adminのgitosis.confにgitwebからの参照許可設定を追加
[gitosis]
gitweb = yes