Install Mercurial on ubuntu, and use nginx for authority management


1.Install mercurial and nginx

Shell:
  1. sudo apt-get install python2.6  
  2. sudo apt-get install python-all-dev   
  3. sudo apt-get install python-setuptools   
  4. sudo easy_install -U mercurial   
  5. hg --version  

 

nginx, you can read the officer document。

 

2.set center repository

create a local repository

Shell:
  1. mkdir -p /var/hg/depo1  
  2. cd /var/hg/depo1  
  3. hg init  

 create config file

Shell:
  1. vi /var/hg/depo1/hgweb.config  

 write the follows in it and save

  1. [web]  
  2. push_ssl = false  
  3. allow_push = *  
  4. encoding = "UTF-8"  
  5. [paths]  
  6. /depo1 = /var/hg/depo1  
  7.   
  8. [hooks]  
  9. changegroup = hg update  

 (set hook,so it will be auto update after push)

start service

Shell:
  1. hg --cwd /var/hg/depo1 serve -d -a localhost --webdir-conf hgweb.config  

 
(-a localhost will not allowed others to access port 8000 of the server)

 

3.config nginx

download  http://trac.edgewall.org/browser/trunk/contrib/htpasswd.py and copy it to /etc/nginx for create users and password

create password files

Shell:
  1. cd /etc/nginx/  
  2. python htpasswd.py -c -b htpasswd useraaa1 123  
  3. python htpasswd.py -b htpasswd useraaa2 123  
  4. python htpasswd.py -b htpasswd useraaa3 123  

 

edit the config file of nginx

Shell:
  1. vi /etc/nginx/nginx.conf  

 add the follows in http{}:

  1. client_max_body_size 20m;  

 

Shell:
  1. vi /etc/nginx/sites-enabled/default  


add the follows,

 
  1. location /depo1 {  
  2.     root   html;  
  3.     index  index.html index.htm;  
  4.     proxy_pass  http://127.0.0.1:8000;  
  5.     auth_basic "Restricted";  
  6.     auth_basic_user_file htpasswd;  
  7. }  


restart ngxin

Shell:
  1. service nginx restart  

 

4.finished

Now you can use http://hostname/depo1 to access the repository.
 

Blog

Blog system is a place where we share our Design and programming technoligy instruction and experience,Project mangement and Team building experience. Pay attention to our blog, and you can get our team's advices and thoughts. Please don't hate to post us a reply if you have question or suggestiion for us.

Reply to our blog

Title

Name

Email

Subscribe

tag Cloud