In "Publishing Mercurial repositories" This article introduces a number of ways to publish/open our own HG code base. One of the lightest methods is to use the HG-brought Web server to publish, only need to execute commands in the code base directory Hg serve is done. But this is only a temporary solution, if you want to be more robust and more secure, the official website is recommended to use the Hgweb script +web server (APACHE,IIS, etc.) way.
After viewing the material, I weigh the pros and cons, and prepare to use the serving Mercurial repositories with Apache and Mod_wsgi and other tutorials and practices to build your own HG server for small partners in the LAN.
1. Tool Mod_wsgi:apache and Python communication Bridge.
Apache2: This guy is still leading the world in Web server.
python:2.7 version is sufficient.
Mercurial: This is our main character.
Hgweb.wsgi:mercurial offered us.
Linc Note: I am a layman in the web, ignorant of the concepts of CGI and WSGI, before the scrum environment was built using a fool-like tool under Windows, there was no chance to configure Apache. So the next job is going to make me miserable. There are also unavoidable shortcomings. More please master correct.
2. Installation I use Apt-get install these tools under Ubuntu, it is very smooth, gossip less.
sudo apt-get install apache2
"It works!" will also appear when you enter localhost in the browser, even if you do not configure it after completion. Then Apache even if the installation is successful.
sudo apt-get install Libapache2-mod-wsgi
After installation in the/usr/lib/apache2/modules/directory will find a lot of mod_wsgi.so
lrwxrwxrwx 1 root root 00:50 mod_wsgi.so-mod_wsgi.so-2.7-rw-r--r--1 root root 152064 Nov 00:50 MoD _wsgi.so-2.7
3. About the Apache directory this little Thing 1)/var/www
This directory is used to place the portal of our site, by default there will be a index.html, just now we open the interface of localhost is this index.html. Later we will make a fuss in this directory.
2)/etc/apache2
We want to do Apache configuration here, the key files are apache2.conf,httpd.conf, and sites-available under the default.
4. Configure the following tutorial example, I also use the virtual host "hg.example.net" to complete the configuration.
first step, load Mod_wsgi
Our configuration (user configurations) is performed in/etc/apache2/httpd.conf,
Load Mod_wsgi Just add LoadModule wsgi_module modules/mod_wsgi.so.
Linc Note: Later I commented out the sentence and found that it was still working.
Step Two, configure Apache
According to the example, we should do the following work.
1) Create a new folder under www
/var/www/vhosts/hg.example.net/cgi-bin
/var/www/vhosts/hg.example.net/htdocs
2) Modify/etc/apache2/sites-avaiable/default
becomes as follows:
<virtualhost *:80> ServerName hg.example.net Documentroot/var/www/vhosts/hg.example.net/htdocs wsgiscriptaliasmatch ^ (. *) $/var/www/vhosts/hg.example.net/cgi-bin/hgweb.wsgi$1 <directory/var/www/ vhosts/hg.example.net/htdocs> Options followsymlinks directoryindex index.html allowoverride None Order Allow,deny Allow from all </Directory> <Directory/var/www/vhosts/hg.example.net/cgi-bin> Options execcgi followsymlinks AddHandler wsgi-script. Wsgi allowoverride None Order allow,deny allow From all </Directory></VirtualHost>
step Three, configure mercurial
1) Copy the Hgweb.wsgi file to the/var/www/vhosts/hg.example.net/cgi-bin/
sudo cp/usr/share/doc/mercurial-common/examples/hgweb.wsgi/var/www/vhosts/hg.example.net/cgi-bin/
Modified to read as follows:
# Path to repo or Hgweb config to serve (see ' HG help hgweb ') config = "/var/www/vhosts/hg.example.net/cgi-bin/hgweb.config "# Enable demandloading to reduce startup Timefrom mercurial import Demandimport; Demandimport.enable () from mercurial.hgweb import hgwebapplication = hgweb (config)
2) Hgweb.config
New in/var/www/vhosts/hg.example.net/cgi-bin/file Hgweb.config
Inside as follows:
[Web]style = coal[paths]/=/var/www/vhosts/hg.example.net/htdocs/**
To restart Apache:
sodu/etc/init.d/apache2 Restart
Here, "serving Mercurial repositories with Apache and Mod_wsgi" is over.
Fourth Step, create HG code warehouse
Where do you put the code? There is no good idea, see someone put it under/Var, let me do it.
New Catalog/var/hg/repos/test,
mkdir/var/hg/repos/test; cd/var/hg/repos/test; HG Init
A temporary code warehouse is created, how do you relate to the server?
Back, we have to revise the Hgweb.config, add the following two sentences:
[COLLECTIONS]/VAR/HG =/VAR/HG
After restarting Apache, enter in the browser: localhost/repos/test
Your code base is there. This means that our work is done. You might want to ask, is it OK to enter hg.example.net directly in the browser? This is the case, but we have to do a job to add 127.0.0.1 hg.example.net to the/etc/hosts file.
All right, let's celebrate, here's the problem with the code submission and the identity authentication issue.
Reference:
Http://mercurial.selenic.com/wiki/PublishingRepositories
Http://mercurial.selenic.com/wiki/modwsgi
Http://stackoverflow.com/questions/12347373/how-to-setup-mercurial-server-in-ubuntu-to-serve-60-repositories
Http://thepanz.netsons.org/post/ubuntu-10-4-and-mercurial-server-apache2-mod_wsgi/comment-page-1
Http://blog.sina.com.cn/s/blog_4567bb800100whho.html
http://blog.csdn.net/tony1130/article/details/5326015
http://blog.csdn.net/kongdaoxian/article/details/7944872
Assault Mercurial SCM (HG) 5---Ubuntu under APACHE+MOD_WSGI build HG server