Skip to content

Instantly share code, notes, and snippets.

@michelep
Created August 24, 2021 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michelep/6095f4fc1c71cce81dda67eac22bb68e to your computer and use it in GitHub Desktop.
Save michelep/6095f4fc1c71cce81dda67eac22bb68e to your computer and use it in GitHub Desktop.
How To Install A Public Git Repository On A Debian Server.
How To Install A Public Git Repository On A Debian Server.
General steps
Install git + gitweb
$ sudo apt-get install git-core gitweb
Setup gitweb directories
$ sudo mkdir /var/www/git
$ [ -d "/var/cache/git" ] || sudo mkdir /var/cache/git
Setup gitweb's Apache config
$ sudo vim /etc/apache2/conf.d/git
contents of file:
<Directory /var/www/git>
Allow from all
AllowOverride all
Order allow,deny
Options ExecCGI
<Files gitweb.cgi>
SetHandler cgi-script
</Files>
</Directory>
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
Copy gitweb files to Apache
$ sudo mv /usr/share/gitweb/* /var/www/git
$ sudo mv /usr/lib/cgi-bin/gitweb.cgi /var/www/git
Setup gitweb.conf
$ sudo vim /etc/gitweb.conf
Contents of gitweb.conf:
$projectroot = '/var/cache/git/';
$git_temp = "/tmp";
#$home_link = $my_uri || "/";
$home_text = "indextext.html";
$projects_list = $projectroot;
$stylesheet = "/git/gitweb.css";
$logo = "/git/git-logo.png";
$favicon = "/git/git-favicon.png";
Reload/Restart Apache
$ sudo /etc/init.d/apache2 reload
Setup Git Repository
$ mkdir -p /var/cache/git/project.git && cd project.git
$ git init
Configure Repository
$ echo "Short project's description" > .git/description
$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"
$ git commit -a
$ cd /var/cache/git/project.git && touch .git/git-daemon-export-ok
Start Git Daemon
$ git daemon --base-path=/var/cache/git --detach --syslog --export-all
Test clone the Repository (from a secondary machine)
$ git clone git://server/project.git project
Adding additional Repos + Users
To add more repos simply repeat steps #7 - #9. To add users just create Unix accounts for each additional user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment