setting up central mercurial server in ubuntu
2011-10-18 14:58
302 查看
ref: http://phpfour.com/blog/2011/05/setting-up-central-mercurial-server-in-ubuntu/
It’s been a while since we’ve been thinking about moving to Mercurial from Subversion at our company.
We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team is already up to speed with it.
Although it’s quite simple to install it in a central server, the different articles on the web had me confused with too many options or with a different distro than Ubuntu. So, here is a dead simple list of things to do for installing Mercurial centrally for
your dev team.
1. Log onto your server using SSH
ssh admin@rbs-server.com
2. Install mercurial from repository:
sudo apt-get
update
sudo apt-get
install mercurial
3. We need to have a directory to store our Mercurial configuration and repository files, so let’s create one and change it’s owner to the apache user so that apache can access them:
cd /var/
sudo mkdir hg
sudo mkdir hg/repos
sudo chown -R www-data:www-data
hg/repos
4. We’ll be creating a configuration that will allow us to host multiple repositories in this server. And we’ll be using CGI to serve the files through Apache:
cd /var/hg
sudo cp /usr/share/doc/mercurial/examples/hgweb.cgi
.
sudo chmod a+x
hgweb.cgi
5. We need to show the location of the config file to the CGI script, so open the file hgweb.cgi with nano or vim to update the line with “config = …” with the following and save it.
config = "/var/hg/hgweb.config"
6. Now let’s create the file /var/hg/hgweb.config and write the location of the repositories:
sudo nano hgweb.config
Enter the following content and save the file:
[collections]
/var/hg/repos = /var/hg/repos
7. As a final step, we’ll need to update the Apache configuration so that it executes the CGI when requested with a /hg prefix:
cd /etc/apache2/sites-available
sudo nano default
At the end of the defaul virtual host configuration and just before the </VirtualHost> tag, add the following and save it:
ScriptAlias /hg "/var/hg/hgweb.cgi"
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /var/hg/hgusers
Require valid-user
8. In order to take effect of the above change, we’ll need to restart apache:
sudo apache2ctl
restart
9. Now you should be able to visit the server’s /hg location like http://rbs-server.com/hg from browser. However, you’ll be greeted with a username/password prompt as we’ve enabled that in our apache configuration above. So, lets add some user
for our use.
cd /var/hg
htpasswd -mc hgusers admin
It will ask for the password of the user admin twice and after you enter that, it will be stored in the file hgusers. You can add more users in the similar fashion, just ignore the c parameter as it was used to create the file
first time:
htpasswd -m hgusers abid
htpasswd -m hgusers saeed
...
10. Now visit the /hg path in your browser and you’ll see the empty list of repositories after you authenticate.
11. By default Mercurial only allows pushing changes through SSL, but in our case it was not necessary. Also, we wanted to give all our developers the push access to the repositories. For that, let’s update the system-wide mercurial configuration file /etc/mercurial/hgrc by
adding the following lines at the end of the file and saving it:
[web]
allow_push = *
push_ssl = false
12. Now that all is set, let’s setup a test repository so that we can clone it in our development machine:
cd /var/hg/repos
mkdir test
cd test
hg init
This repository can now be accessed through http://rbs-server.com/hg/test and can be cloned in a development machine with the following command (mercurial must be installed already):
cd /var/www
hg clone http://rbs-server.com/hg/test
Hope this will make someone’s life easy. Enjoy the beauty of Mercurial!
It’s been a while since we’ve been thinking about moving to Mercurial from Subversion at our company.
We were convinced about the benefits of DVCS and chose Mercurial over Git. However, due to pressure at work and some procrastination, the move was delayed a couple times. Finally, today we had the move and the team is already up to speed with it.
Although it’s quite simple to install it in a central server, the different articles on the web had me confused with too many options or with a different distro than Ubuntu. So, here is a dead simple list of things to do for installing Mercurial centrally for
your dev team.
1. Log onto your server using SSH
ssh admin@rbs-server.com
2. Install mercurial from repository:
sudo apt-get
update
sudo apt-get
install mercurial
3. We need to have a directory to store our Mercurial configuration and repository files, so let’s create one and change it’s owner to the apache user so that apache can access them:
cd /var/
sudo mkdir hg
sudo mkdir hg/repos
sudo chown -R www-data:www-data
hg/repos
4. We’ll be creating a configuration that will allow us to host multiple repositories in this server. And we’ll be using CGI to serve the files through Apache:
cd /var/hg
sudo cp /usr/share/doc/mercurial/examples/hgweb.cgi
.
sudo chmod a+x
hgweb.cgi
5. We need to show the location of the config file to the CGI script, so open the file hgweb.cgi with nano or vim to update the line with “config = …” with the following and save it.
config = "/var/hg/hgweb.config"
6. Now let’s create the file /var/hg/hgweb.config and write the location of the repositories:
sudo nano hgweb.config
Enter the following content and save the file:
[collections]
/var/hg/repos = /var/hg/repos
7. As a final step, we’ll need to update the Apache configuration so that it executes the CGI when requested with a /hg prefix:
cd /etc/apache2/sites-available
sudo nano default
At the end of the defaul virtual host configuration and just before the </VirtualHost> tag, add the following and save it:
ScriptAlias /hg "/var/hg/hgweb.cgi"
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /var/hg/hgusers
Require valid-user
8. In order to take effect of the above change, we’ll need to restart apache:
sudo apache2ctl
restart
9. Now you should be able to visit the server’s /hg location like http://rbs-server.com/hg from browser. However, you’ll be greeted with a username/password prompt as we’ve enabled that in our apache configuration above. So, lets add some user
for our use.
cd /var/hg
htpasswd -mc hgusers admin
It will ask for the password of the user admin twice and after you enter that, it will be stored in the file hgusers. You can add more users in the similar fashion, just ignore the c parameter as it was used to create the file
first time:
htpasswd -m hgusers abid
htpasswd -m hgusers saeed
...
10. Now visit the /hg path in your browser and you’ll see the empty list of repositories after you authenticate.
11. By default Mercurial only allows pushing changes through SSL, but in our case it was not necessary. Also, we wanted to give all our developers the push access to the repositories. For that, let’s update the system-wide mercurial configuration file /etc/mercurial/hgrc by
adding the following lines at the end of the file and saving it:
[web]
allow_push = *
push_ssl = false
12. Now that all is set, let’s setup a test repository so that we can clone it in our development machine:
cd /var/hg/repos
mkdir test
cd test
hg init
This repository can now be accessed through http://rbs-server.com/hg/test and can be cloned in a development machine with the following command (mercurial must be installed already):
cd /var/www
hg clone http://rbs-server.com/hg/test
Hope this will make someone’s life easy. Enjoy the beauty of Mercurial!
相关文章推荐
- Setting Up a Telnet Server in Ubuntu
- Setting Up an Ubuntu Subversion Server
- 转载:Setting Up ADB/USB Drivers for Android Devices in Linux (Ubuntu)
- Setting up a Passive FTP Server in Windows Azure VM(ReplyCode: 227, Entering Passive Mode )
- Setting up Telnet server on Ubuntu
- Setting up Minicom in Ubuntu
- Setting up Minicom in Ubuntu
- Setting up NFS on Ubuntu 10.04 Server
- Setting up Ubuntu in CoLinux–changing local/keyboard to be English
- Setting up a Subversion Server on Ubuntu Gutsy Gibbon server
- Setting up OpenCV with Qt Creator in Ubuntu 13.10
- Setting Up Transmission-Daemon To Use With Remote GUI In Ubuntu And Debian
- Setting up Qt Development in Ubuntu 9.04
- Setting up an OpenGL development environment in ubuntu
- Setting up a static IP address in Ubuntu
- Setting up Wi-Fi Authentication in Windows Server 2008
- How to Install a VNC Server in Ubuntu
- Setting up Django and your web server with uWSGI and nginx
- Gitweb and apache server in ubuntu 10.04
- Setting up SSL with a SelfSSL certificate on Windows Server 2003