1.15.2015

Git - gitweb gitolite3 apache2 on Ubuntu

Work on ubuntu 14.04 LTS x64

1. Install Software
Install git gitweb apache2
sudo apt-get install git gitweb apache2

Install gitolite3

search "Synaptic Package Manager" in Ubuntu Software Center
search "gitolite3" in Synaptic Package Manager then install

2. Configure gitweb
Fix Apache2
sudo cp /etc/apache2/conf.d/gitweb /etc/apache2/conf-available/gitweb.conf
cd /etc/apache2/conf-enabled
sudo ln -s ../conf-available/gitweb.conf

Then modify gitweb.conf add "+" before FollowSymLinks look like
Alias /gitweb /usr/share/gitweb
<Directory /usr/share/gitweb>
  Options +FollowSymLinks +ExecCGI
  AddHandler cgi-script .cgi
</Directory>

Run following command
sudo a2enmod cgid
sudo service apache2 restart

Modefy gitweb in /etc/gitweb.conf
$projectroot = "/home/git/repositories/";
$projects_list = "/home/git/projects.list";

3. Configure gitolite3
Add git user
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
Add user www-data to group git
sudo usermod -G git www-data

Create private and public key
cd ~/.ssh/
ssh-keygen -t rsa
sudo cp id_rsa.pub /home/git/tmp/admin.pub

Setup gitolite3 (Change user to git)
sudo su git
gitolite setup -pk /home/git/tmp/admin.pub

In /home/git/.gitolite.rc make sure
UMASK => 0027

chmod 640 /home/git/projects.list

exit
(Exit user from git)

4. Configure admin
Setup git 
git config --globla uer.name "yourname"
git config --global user.email "youremail@domain.com"

Clone gitolite-admin
cd /yourpath/
git clone git@your-server-ip:gitolite-admin.git

Add new user (you can read step.5 first)
(copy your newuser.pub to the sever put in /yourpah/gitolite-admin/keydir/)
cp newuser.pub /yourpath/gitolite-admin/keydir/newuser.pub
git add /yourpath/gitolite-admin/keydir/newuser.pub
git commit -a -m "create new repo and added newuser"
git push -u origin master

5. Configure NewUser
Create private and public key 
cd ~/.ssh/
ssh-keygen -t rsa
sudo mv id_rsa.pub newuser.pub
goto step.4 Add new user

6. Check gitweb
http://localhost/gitweb or http://your-server-ip/gitweb

Debug Command
Check ssh connection log
ssh -v git@your-server-ip
Check connection with server
ssh git@your-server-ip info

Reference

No comments: