gitweb
First of all, you have to install gitweb:
# apt-get install gitweb
You have to create a directory to git-web:
# mkdir /var/www.git
# chown -R www-data:www-data /var/www.git
Edit the file /etc/apache2/conf-available/gitweb.conf (OLD: /etc/apache2/conf.d/gitweb):
Alias /gitweb /var/www.git
<Directory /var/www.git>
Order allow,deny
Allow from all
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
RewriteEngine on
RewriteRule ^([^.]+\.git.*)$ /gitweb/gitweb.cgi/$0 [L,PT]
</Directory>
Copy the following files:
# cp -vr /usr/share/gitweb/* /var/www.git
# cp -v /usr/lib/cgi-bin/gitweb.cgi /var/www.git
# chown -R www-data:www-data /var/www.git
Edit the file /etc/gitweb.conf:
# path to git projects (<project>.git)
$projectroot = "/var/GIT";
# directory to use for temp files
$git_temp = "/tmp";
# target of the home link on top of all pages
#$home_link = $my_uri || "/";
# html text to include at home page
#$home_text = "indextext.html";
# file with project list; by default, simply scan the projectroot dir.
#$projects_list = $projectroot;
# stylesheet to use
#@stylesheets = ("static/gitweb.css");
# javascript code for gitweb
#$javascript = "static/gitweb.js";
# logo to use
#$logo = "static/git-logo.png";
# the 'favicon'
#$favicon = "static/git-favicon.png";
# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();
Add the following file /etc/apache2/sites-available/git.conf:
<VirtualHost *:80>
ServerAdmin oscargomezf@gmail.com
ServerName gitweb.net
ServerAlias www.gitweb.net
DocumentRoot /var/www.git
SetEnv GITWEB_CONFIG /etc/gitweb.conf
SetEnv GIT_PROJECT_ROOT /var/GIT
# Enable git clone over HTTP
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/usr/lib/git-core/git-http-backend/$1
ErrorLog ${APACHE_LOG_DIR}/server.git.net-error.log
CustomLog ${APACHE_LOG_DIR}/server.git.net-access.log combined
</VirtualHost>
Add the following file /etc/apache2/sites-available/git-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin oscargomezf@gmail.com
ServerName gitweb.net
ServerAlias www.gitweb.net
DocumentRoot /var/www.git
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/usr/lib/git-core/git-http-backend/$1
ErrorLog ${APACHE_LOG_DIR}/error_git_ssl.log
CustomLog ${APACHE_LOG_DIR}/access_git_ssl.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/certificates/apache-selfsigned.crt
SSLCertificateKeyFile /etc/apache2/certificates/apache-selfsigned.key
</VirtualHost>
</IfModule>
Enable these sites:
$ a2ensite git
$ a2ensite git-ssl
Add the entry to /etc/apache2/apache2.conf:
...
<Directory /var/www.git/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
...
10. Add the following modules:
# a2enmod rewrite
# a2enmod cgi
11. Restart apache2:
$ systemctl restart apache2