zoukankan      html  css  js  c++  java
  • Ubuntu下搭建基于apache2的gerrit+gitweb服务器

    说明:Ubuntu版本12.04

    1. 配置gerrit管理帐号

    1
    sudo adduser gerrit

      增加sudo权限:

    1
    sudo usermod -a -G sudo gerrit

      切换到gerrit账号:

    1
    sudo su gerrit

    2. 安装java

    1
    2
    3
    sudo add-apt-repository ppa:openjdk-r/ppa
    sudo apt-get update
    sudo apt-get install openjdk-7-jdk

    3. 安装git

    1
    sudo apt-get install git

    4. 安装配置apache2

    1
    sudo apt-get install apache2

    修改配置文件:

    1
    sudo vi /etc/apache2/httpd.conf

    具体内容如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    <VirtualHost *:8081>
         
        ServerName 192.168.130.10
     
        ProxyRequests Off
        ProxyVia Off
        ProxyPreserveHost On
     
        <Proxy *>
              Order deny,allow
              Allow from all
        </Proxy>
     
        <Location "/login/">
            AuthType Basic
            AuthName "Gerrit Code Review"
            Require valid-user
            AuthBasicProvider file
            AuthUserFile /home/gerrit/review_site/passwords
        </Location>
     
        AllowEncodedSlashes On
        
        ProxyPass / http://127.0.0.1:8091/ nocanon
     
    </VirtualHost>

    注:如httpd.conf没有Include到apache2.conf中,需手动添加:

    1
    sudo vi /etc/apache2/apache2.conf

    添加,

    1
    Include httpd.conf

    修改配置文件,添加对8081端口的监听:

    1
    sudo vi /etc/apache2/ports.conf

    添加,

    1
    Listen 8081

    开启SSL、Proxy、Rewrite等模块:

    1
    cd /etc/apache2/mods-enabled/
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    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

    5. 安装配置gerrit

    本文用的版本是gerrit-2.13.6。
    安装:
    1
    java -jar gerrit-2.13.6.war init -d ~/review_site

    安装配置先选择默认配置,安装完成后再来修改配置文件:

    1
    vi ~/review_site/etc/gerrit.config

    具体内容如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    [gerrit]
            basePath = git
            serverId = 02481fa0-9b63-4b6a-9869-8b4e2a4364ee
            canonicalWebUrl = http://192.168.130.10:8081/
    [database]
            type = h2
            database = /home/gerrit/review_site/db/ReviewDB
    [auth]
            type = HTTP
    [receive]
            enableSignedPush = false
    [sendemail]
            smtpServer = smtp.company.com
            smtpServerPort = ***
            smtpEncryption = ssl 
            smtpUser = user@company.com
            smtpPass = ******
            sslVerify = false 
            from = Code Review < gerrit@company.com >
    [container]
            user = gerrit
            javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
    [sshd]
            listenAddress = *:29418
    [httpd]
            listenUrl = proxy-http://*:8091/
    [cache]
            directory = cache
     
    接下来,配置gerrit账户:
     
    1
    2
    touch ~/review_site/passwords
    sudo htpasswd -b ~/review_site/passwords admin 123123

    6. 安装配置gitweb

    1
    sudo apt-get install gitweb

    查看相关配置文件安装路径:

    1
    dpkg -L gitweb

    得到输出如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    /.
    /usr
    /usr/share
    /usr/share/doc
    /usr/share/doc/gitweb
    /usr/share/doc/gitweb/examples
    /usr/share/doc/gitweb/examples/index.aux-generation
    /usr/share/doc/gitweb/README.Debian
    /usr/share/doc/gitweb/copyright
    /usr/share/doc/gitweb/README
    /usr/share/doc/gitweb/NEWS.Debian.gz
    /usr/lib
    /usr/lib/cgi-bin
    /etc
    /etc/apache2
    /etc/apache2/conf.d
    /etc/apache2/conf.d/gitweb
    /etc/gitweb.conf
    /usr/share/doc/gitweb/changelog.Debian.gz
    /usr/lib/cgi-bin/gitweb.cgi

    根据上面的地址在gerrit.conf中添加如下配置:

    1
    2
    3
    [gitweb]
        type = gitweb
        cgi = /usr/lib/cgi-bin/gitweb.cgi

    相关说明:

    gitweb集成gerrit后,默认只有管理员用户才能查看gitweb超链接,普通用打开链接后页面显示Not Found。如果想给普通的用户查看gitweb超链接的权限,则必须对项目设置refs/meta/config 的read权限。而这个权限在All-Projects的ACL里只对Administrators用户和Project Owners开放。

    7. 重启gerrit和apache2

    1
    2
    sudo ~/review_site/bin/gerrit.sh restart
    sudo /etc/init.d/apache2 restart

    8. 访问gerrit 管理界面

    浏览器输入:

    1
    http://192.168.130.10:8081/

    在弹出框输入htpasswd命令设置的账号密码即可。

  • 相关阅读:
    有关javamelody的配置
    jsp页面路径问题
    mavne问题解决---Dynamic Web Module 2.3 or newer
    centos配置数据源和java环境配置
    iBatis之Iterator的使用
    [转]Android MediaPlayer状态机
    [转]Android Activity的加载模式和onActivityResult方法之间的冲突
    ubuntu1304无法启动桌面系统的问题和解决
    java使用AES256解密
    [转]理解Linux的处理器负载均值
  • 原文地址:https://www.cnblogs.com/jiangzhaowei/p/7874851.html
Copyright © 2011-2022 走看看