前言
Gitweb提供了git版本库的图形化web浏览功能。可以到网站http://git.kernel.org/体验下效果
安装系统 Ubuntu 18.04
安装apach2
sudo apt-get install apache2
安装gitweb
sudo apt-get install gitweb
配置修改
sudo vi /etc/apache2/httpd.conf
#<IfModule mod_ssl.c> #开启ssl时开启
<VirtualHost *:8082> #开启ssl时改为443
ServerName 192.168.x.xxx #本机ip
DocumentRoot /home/git/review_site/git
# Deny to access to .htaccess etc
<Files ~ "(^\.htaccess|^.*\.conf)">
Order allow,deny
Deny from all
</Files>
# OPTIONAL: Completely deny pushing over HTTP
# <LocationMatch "git-receive-pack">
# Order Allow,Deny
# Deny from all
# </LocationMatch>
<Directory /usr/share/gitweb>
Options ExecCGI FollowSymLinks
Order allow,deny
Allow from all
</Directory>
<Location />
AuthType Basic
AuthName "Git Repositories"
AuthUserFile /home/git/review_site/etc/web_passwords
#Require valid-user #开启登录用户验证时开启
Order allow,deny
Allow from all
</Location>
Options ExecCGI FollowSymLinks
AddHandler cgi-script cgi
SetEnv GIT_PROJECT_ROOT /git
SetEnv GIT_HTTP_EXPORT_ALL
# Note: Serve static files directly
AliasMatch ^/static/(.*)$ /usr/share/gitweb/static/$1
AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /git/$1
AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /git/$1
# Note: Serve repository objects with Git HTTP backend
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/info/[^/]+ | \
git-(upload|receive)-pack))$" \
/usr/lib/git-core/git-http-backend/$1
ScriptAlias / /usr/share/gitweb/gitweb.cgi
RewriteEngine on
RewriteRule ^/$ /usr/share/gitweb/gitweb.cgi [L]
RewriteRule ^/(\w+\.git)$ /?p=$1 [R]
ErrorLog ${APACHE_LOG_DIR}/git_error.log
CustomLog ${APACHE_LOG_DIR}/git_access.log combined
#开启ssl时开启,git.service.com改为秘钥所在文件夹,git.service.com或service.com都有可能
#SSLCertificateFile /etc/letsencrypt/live/git.service.com/fullchain.pem
#SSLCertificateKeyFile /etc/letsencrypt/live/git.service.com/privkey.pem
#Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
#</IfModule>
sudo vi /etc/apache2/apache2.conf
Include httpd.conf
sudo vi /etc/apache2/ports.conf
Listen 8082 //这里的8082端口号是上面配置的Apache2反射端口
开启SSL、Proxy、Rewrite等模块:
cd /etc/apache2/mods-enabled
在这个路径下面,输入下面的命令
sudo ln -s ../mods-available/proxy.load
sudo ln -s ../mods-available/proxy.conf
sudo ln -s ../mods-available/proxy_http.load
sudo ln -s ../mods-available/proxy_balancer.conf
sudo ln -s ../mods-available/proxy_balancer.load
sudo ln -s ../mods-available/rewrite.load
sudo ln -s ../mods-available/ssl.conf
sudo ln -s ../mods-available/ssl.load
sudo ln -s ../mods-available/slotmem_shm.load
sudo ln -s ../mods-available/socache_shmcb.load
重启apach2即可
sudo /etc/init.d/apache2 restart
最后浏览器输入
http://192.168.x.xxx:8082/