1. 安装Apache: sudo apt-get install apache2
  2. 安装mod_wsgi: sudo apt-get install libapache2-mod-wsgi
  3. 安装Mercurial:源码安装,稳定版,见hg安装(目前是2.4)的下载网页[1] hgweb.wsgi在源码mercurail-2.4/contrib下
  4. 配置hgrc

    sudo mkdir /etc/mercurial

     

    添加:

    [web]

    allow_push = *

    push_ssl = false

    allow_archive = gz, zip, bz2

    [trusted]

    users = www-data

  5. .hgrc的添加:

    cd

    vim .hgrc

    #type the following

    [ui]

    username = usertest

  6. 建立测试目录:

    cd ~  # go to home directory

    mkdir repository1

    cd repository1

    hg init

    echo Hello World! > readme.txt

    hg add readme.txt

    hg status

    hg commit -m 'My first repository!'

    hg tip  # shows the tip of the repository

  7. 建立主机目录

    cd /var

    sudo mkdir hg

    sudo mkdir hg/repositories

    sudo chown -R root:www-data hg

  8. 配置hgweb.config文件

    cd /var/hg

    sudo vim hgweb.config

    #type following

    [web]
    style = gitweb
    [collections]
    /var/hg/repositories = /var/hg/repositories

  9. 配置hgweb.wsgi

    cd /var/hg

    sudo cp /home/lijian/Downloads/mercurial-2.4/contrib/hgweb.wsgi .

    sudo chmod a+x hgweb.wsgi

    sudo vim hgweb.wsgi

    修改:

    config = "/var/hg/hgweb.config"

  10. 配置apache

    cd /etc/apache2/

    sudo mkdir mercurial

    cd mercurial/

    sudo vim mercurial.conf

    内容:

    WSGIScriptAliasMatch  ^/hg(.*) /var/hg/hgweb.wsgi$1
    <Directory "/var/hg/">
    Options Indexes FollowSymlinks MultiViews ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthName "Mercurial Repositories"
    AuthUserFile /var/hg/hgusers
    Require valid-user
    </Directory>

    cd /etc/apache2/sites-available

    sudo nano default

    # Type on the line before

    Include /etc/apache2/mercurial/mercurial.conf

    #restart the apache server so the changes take effect

    sudo apache2ctl restart

    如有问题查看/var/log/apache2/error.log [tail /var/log/apache2/error.log]


  11. 测试

    cd ~ # go to your home drive
    sudo mv test/ /var/hg/repositories/.
    sudo chown -R root:www-data /var/hg/

  12. 建立用户密码文件

    cd /var/hg

    sudo htpasswd -mc hgusers admin #建立admin

    sudo chown root:www-data hgusers

  13. 添加其它用户

    cd /var/hg

    sudo htpasswd -m hgusers {username}# 添加用户username

  14. 用http://localhost/hg,访问

    Image

参考:

[1]: [http://mercurial.selenic.com/release/?M=D]

[2]:[http://omarfrancisco.com/setting-up-a-mercurial-repository-in-ubuntu-11-10/]

[3]:[http://www.linuxidc.com/Linux/2011-07/39290.htm]

[4]:官网介绍:[http://mercurial.selenic.com/wiki/PublishingRepositories]

posted on 2012-11-23 20:13  hustlijian  阅读(703)  评论(0编辑  收藏  举报

无觅相关文章插件,快速提升流量