-
-
Save synsa/ce2d9e30a4d1d70b1fec21b3be26c0ff to your computer and use it in GitHub Desktop.
Create own Git Server with Gitolite and Gitweb in Ubuntu (Gitolite + GitWeb)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get install git-core | |
sudo adduser \ | |
--system \ | |
--shell /bin/bash \ | |
--gecos 'git version control' \ | |
--group \ | |
--disabled-password \ | |
--home /home/git git | |
sudo su -l git | |
cd /home/git && git clone git://github.com/sitaramc/gitolite | |
mkdir $HOME/bin | |
# Verification | |
# ------------------------------ | |
# git@ubuntu:~$ ls bin/gitolite | |
# bin/gitolite | |
# git@ubuntu:~$ | |
# ------------------------------ | |
# ssh key generation and we have to type one and more enter key to check some interactive message. | |
# In your Linux client and run your-name@your-ip-address-or-hostname:~$ ssh-keygen -t rsa -C "Git-Admin" | |
# If you have already had the id_rsa.pub, we can skip previous step and run following command directly: | |
# scp ~/.ssh/id_rsa.pub username@git-server-FQDN-or-its-ip-address:~ then go back to the git-server | |
sudo mv id_rsa.pub /home/git/Git-Admin.pub && sudo chown git:git /home/git/Git-Admin.pub | |
sudo su -l git | |
bin/gitolite setup -pk Git-Admin.pub | |
# Verification | |
# ls -al | |
# ls -al repositories/ | |
# Go back to your client | |
# your-name@your-ip-address-or-hostname:~$ sudo apt-get install git | |
# your-name@your-ip-address-or-hostname:~$ cd ~/Desktop | |
# your-name@your-ip-address-or-hostname:~$ git config --global user.name "your user name" | |
# your-name@your-ip-address-or-hostname:~$ git config --global user.email "your email" | |
# your-name@your-ip-address-or-hostname:~$ | |
# your-name@your-ip-address-or-hostname:~$ git config --list | |
# clone repo for git server | |
# git clone git@your-ip-address-or-hostname:gitolite-admin.git | |
# your-name@your-ip-address-or-hostname:~/Desktop$ | |
# your-name@your-ip-address-or-hostname:~/Desktop$ cd gitolite-admin/ | |
# your-name@your-ip-address-or-hostname:~/Desktop/gitolite-admin$ ls | |
# conf keydir | |
# your-name@your-ip-address-or-hostname:~/Desktop/gitolite-admin$ cd conf/ | |
# your-name@your-ip-address-or-hostname:~/Desktop/gitolite-admin/conf$ | |
# your-name@your-ip-address-or-hostname:~/Desktop/gitolite-admin/conf$ ls | |
# gitolite.conf | |
# your-name@your-ip-address-or-hostname:~/Desktop/gitolite-admin/conf$ cat gitolite.conf | |
# repo gitolite-admin | |
# RW+ = Git-Admin | |
# repo testing | |
# RW+ = @all | |
# your-name@your-ip-address-or-hostname:~/Desktop/gitolite-admin/conf$ | |
# git push testing | |
# your-name@your-ip-address-or-hostname:cd ~/Desktop/gitolite-admin/conf | |
# your-name@your-ip-address-or-hostname:ls -l gitolite.conf | |
# your-name@your-ip-address-or-hostname:git add gitolite.conf | |
# your-name@your-ip-address-or-hostname:git commit -m "first commit" | |
# your-name@your-ip-address-or-hostname:git push origin master | |
# Install and configure GitWeb on our private git server | |
sudo apt-get install gitweb apache2 | |
sudo usermod -G git www-data | |
chmod -R 750 /home/git/repositories/ | |
# Intall on Ubuntu 14.04 | |
# Setting up gitweb (1:1.9.1-1ubuntu0.3) ... | |
# * Reloading web server apache2 * | |
# Verification | |
# ls -l /usr/share/gitweb/ | |
# total 236 | |
# -rwxr-xr-x 1 root root 236227 Apr 11 2012 gitweb.cgi | |
# lrwxrwxrwx 1 root root 10 Apr 11 2012 index.cgi -> gitweb.cgi | |
# drwxr-xr-x 2 root root 4096 May 31 22:04 static | |
# Edit the /home/git/.gitolite.rc and change the UMASK value as 0027 | |
# sudo vim /home/git/.gitolite.rc | |
# NOTE: Below given step is deleted and should not be followed with new gitweb version 1:1.7.9.5-1+. | |
# If you have older version you can try following step. | |
# ------------------------------ | |
# sudo vim /etc/gitweb.conf | |
# $projectroot = "/home/git/repositories/"; | |
# $projects_list = $projectroot; | |
# ------------------------------ | |
sudo service apache2 restart | |
# ------------------------------ | |
# NOTE | |
# if you have enabled the firewall (we issume that you use the ufw) | |
# sudo ufw allow http | |
# ------------------------------ | |
# ------------------------------ | |
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 | |
sudo a2enmod cgi | |
sudo service apache2 restart | |
# ------------------------------ | |
# /etc/apache2/conf-enabled | |
# Alias /gitweb /usr/share/gitweb | |
# <Directory /usr/share/gitweb> | |
# Options +FollowSymLinks +ExecCGI | |
# AddHandler cgi-script .cgi | |
# AllowOverride All | |
# RewriteEngine On | |
# RewriteCond %{HTTPS} off | |
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# </Directory> | |
# ------------------------------ | |
# Visit the gitweb: http://you-ip-address-or-hostname/gitweb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment