Ubuntu环境下cGit的配置与使用

1、下载cgit
#cd ~
#wget -c https://git.zx2c4.com/cgit/snapshot/cgit-1.1.tar.xz
2、解压cgit
#tar xvf cgit-1.1.tar.xz
3、安装ssl、git或curl
#sudo apt-get install libssl-dev
#sudo apt-get install git
#sudo apt-get install curl
4、安装cgit
#mv cgit-1.1 cgit
#cd cgit
#make get-git
#make
#make install
5、安装apache2
#sudo apt-get install apache2
6、新建配置文件
#sudo touch /etc/apache2/conf-available/cgit.conf
7、配置apache2.conf
增加/etc/apache2/apache2.conf中 conf-available/*.conf
8、配置sites-enabled/000-default.conf
设置DocumentRoot /var/www/htdocs/cgit/
9、新建cgit.sh
#cd ~
#touch cgit.sh
#gedit cgit.sh

#!/bin/sh

set -e

[ -z "${SCAN_PATH}" ] && SCAN_PATH=/home/ubuntu/git

cgit_install()
{
  echo "scan-path=${SCAN_PATH}" | sudo tee -a /etc/cgitrc
  cat <<EOF | sudo tee -a /etc/cgitrc
source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.sh

#virtual root
virtual-root=/

#css logo.
css=/cgit.css
logo=/cgit.png

#project
scan-path=/home/ubuntu/git/

#...
enable-index-links=1
enable-index-owner=1
enable-log-filecount=1
enable-log-linecount=1

#title
root-title=sylixos.com git repositories

#desc
root-desc=Git repositories hosted at sylixos.com
EOF
}

apache_install()
{
  sudo cp /etc/apache2/conf-available/cgit.conf \
       /etc/apache2/conf-available/cgit.conf.orig
  cat <<EOF | sudo tee /etc/apache2/conf-available/cgit.conf
<VirtualHost _default_:80>

ServerAdmin admin@example.com
    ServerName git.njsylixos.com

    DocumentRoot /var/www/htdocs/cgit/

    <Directory /var/www/htdocs/cgit/>
        AllowOverride None
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Directory>

    Alias /cgit.png /var/www/htdocs/cgit/cgit.png
    Alias /cgit.css /var/www/htdocs/cgit/cgit.css
    ScriptAlias / "/var/www/htdocs/cgit/cgit.cgi/"

    ErrorLog /var/log/apache2/cgit-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/cgit-access.log combined

$(sed -e 's/^/  /g' /etc/apache2/conf-available/cgit.conf.orig)
</VirtualHost>
EOF
  sudo a2enmod cgid
  sudo service apache2 restart
}

create_repo()
{
  mkdir -p "${SCAN_PATH}"/test.git
  cd "${SCAN_PATH}"/test.git
  git init --bare
}

cgit_main()
{
  cgit_install
  apache_install
  create_repo
}

cgit_main

执行该脚本:#sudo ./cgit.sh

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值