📜 ⬆️ ⬇️

Own git server based on Ubuntu or Debian / GNU Linux

I’ve met a lot of tutorials on the network to install my git server on both gitweb and webdav, but, alas, they either were only on one of the above points, not covering the other, or didn’t work. Yesterday there was a need to raise your server repositories. I spent a couple of hours - I picked it up, now I want to share my experience, because I consider the problem as topical :)


This tutorial has created the git.shadowircd.net repository .

First, install some of the aptitude packages:
aptitude install git-core git-svn gitweb

Create a folder to store the site with gitweb and dav-version of the git repository:
mkdir -p /www/git.domain.tld/{htdocs,logs} /www/git.domain.tld/htdocs/git

We activate the necessary Apache2 modes:
a2enmod dav
a2enmod dav_fs
a2enmod rewrite
a2enmod env

We compile the gitweb configuration file:
mcedit /www/git.domain.tld/gitweb.conf

It looks like this for me:
$ my_uri = “http: //git.domain.tld”; # repository address
$ site_name = “git.domain.tld”; # site name displayed in title
$ projectroot = “/www/git.domain.tld/htdocs/git/”; # path to git repositories on hard disk
')
$ git_temp = “/ tmp”;
$ home_link = $ my_uri; # link to "homepage"
# $ home_text = “indextext.html”; # text, you can uncomment and insert your
$ projects_list = $ projectroot;
$ stylesheet = “/gitweb/gitweb.css”;
$ logo = “/gitweb/git-logo.png”;
$ favicon = “/gitweb/git-favicon.png”;
$ projects_list_description_width = 40;

$ feature {'pathinfo'} {'default'} = [1];

Now let's move on to our vhost in apache2, this is where the most interesting is contained:
<VirtualHost *: 80>
ServerName git.domain.tld
ServerAlias www.git.domain.tld

ServerAdmin head@coderscamp.ru

DocumentRoot /www/git.domain.tld/htdocs
ScriptAlias ​​/ cgi-bin / / usr / lib / cgi-bin /

DirectoryIndex /cgi-bin/gitweb.cgi

RewriteEngine on
RewriteRule ^ / ([a-zA-Z0-9 _ \ -] + \ / \. Git) /? (\?. *)? $ /Cgi-bin/gitweb.cgi/$1 [L, PT]

SetEnv GITWEB_CONFIG /www/git.domain.tld/gitweb.conf
Alias ​​/ gitweb / usr / share / gitweb /

<Directory /www/git.domain.tld/htdocs>
Options FollowSymLinks
AllowOverride None
Order allow, deny
allow from all
</ Directory>

<Location / git>
DAV on
AuthType Basic
AuthName "Git"
AuthUserFile /www/git.domain.tld/passwd.git
<LimitExcept GET HEAD PROPFIND OPTIONS REPORT>
Require valid-user
</ LimitExcept>
</ Location>

LogLevel warn
ErrorLog /www/git.domain.tld/logs/error.log
CustomLog /www/git.domain.tld/logs/access.log combined
</ Virtualhost>

It remains only to add a new user:
htpasswd -cm /www/git.domain.tld/passwd.git user

Everything We create repositories in /www/git.domain.tld/htdocs/git/ and enjoy the most enjoyable version control system of all :)

PS For Windows users, when using git, the tip about disabling the CRLF line insert extension habrahabr.ru/blogs/development/43808 will be useful

PPS for Linux users - this server works using DAV, problems may arise with push, resolved by creating a ~ / .netrc file with the following contents of machine git.domain.tld login <user> password <password>

Source: https://habr.com/ru/post/43806/


All Articles