mingk 发表于 2015-8-5 09:40:14

mecurial 服务器认证配置(mecurial + apache + mod_wsgi + python )


   [*]安装Apache: sudo apt-get install apache2
[*]安装mod_wsgi: sudo apt-get install libapache2-mod-wsgi
[*]安装Mercurial:源码安装,稳定版,见hg安装(目前是2.4)的下载网页 hgweb.wsgi在源码mercurail-2.4/contrib下
[*]配置hgrc               sudo mkdir /etc/mercurial
  
  添加:
  
  allow_push = *
  push_ssl = false
  allow_archive = gz, zip, bz2
  
  users = www-data
   
[*]     .hgrc的添加:
               cd
  vim .hgrc
  #type the following
  
  username = usertest
   
[*]建立测试目录:               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
   
[*]建立主机目录        cd /var
  sudo mkdir hg
  sudo mkdir hg/repositories
  sudo chown -R root:www-data hg
[*]配置hgweb.config文件        cd /var/hg
  sudo vim hgweb.config
  #type following
        
style = gitweb         
         
/var/hg/repositories = /var/hg/repositories
[*]配置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"
[*]配置apache        cd /etc/apache2/
  sudo mkdir mercurial
  cd mercurial/
  sudo vim mercurial.conf
  内容:
  WSGIScriptAliasMatch^/hg(.*) /var/hg/hgweb.wsgi$1      
         
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         

  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
[*]测试        cd ~ # go to your home drive      
sudo mv test/ /var/hg/repositories/.         
sudo chown -R root:www-data /var/hg/
[*]建立用户密码文件        cd /var/hg
  sudo htpasswd -mc hgusers admin #建立admin
  sudo chown root:www-data hgusers
[*]添加其它用户        cd /var/hg
  sudo htpasswd -m hgusers {username}# 添加用户username
[*]用http://localhost/hg,访问      
  参考:
  : [http://mercurial.selenic.com/release/?M=D]
  :[http://omarfrancisco.com/setting-up-a-mercurial-repository-in-ubuntu-11-10/]
  :官网介绍:[http://mercurial.selenic.com/wiki/PublishingRepositories]
页: [1]
查看完整版本: mecurial 服务器认证配置(mecurial + apache + mod_wsgi + python )