hg.example.com/public
hg.example.com/public
.#
” symbol (the command must be executed with superuser rights); or the “ $
” symbol (the command must be executed with the rights of a regular user).vi
used everywhere, but of course, you can use any other to your liking.mercurial
:<code> # aptitude install mercurial </ code>
/home/hg
.<code> # useradd hg # mkdir / home / hg # chown hg: hg / home / hg </ code>
sudo su - hg
) under this user. Create a directory for the repository (in our example: /home/hg/repo
)<code> $ mkdir / home / hg / repo </ code>
<code> $ mkdir / home / hg / web </ code>
<code> $ cd repo $ hg init </ code>
<code> # aptitude install apache2 apache2-suexec # a2enmod suexec </ code>
hg.example.com
domain. To do this, create a file with the description of the virtual host parameters in the /etc/apache2/sites-available
directory:<code> # vi /etc/apache2/sites-available/hg.regolit.com </ code>
<code> NameVirtualHost *: 80 <VirtualHost *: 80> ServerName hg.example.com DocumentRoot / home / hg / web Suxecusergroup hg hg Alias / public / var / www / hg-public <Directory "/ var / www / hg-public"> Options execcgi DirectoryIndex hgweb.cgi AddHandler cgi-script .cgi Order allow, deny Allow from all AuthUserFile /home/hg/.hg.htpasswd AuthGroupFile / dev / null AuthName "public repo" AuthType Basic <LimitExcept GET> Require valid-user </ LimitExcept> </ Directory> </ Virtualhost> </ code>
<code> # a2ensite hg.example.com # /etc/init.d/apache2 force-reload </ code>
<LimitExcept GET>
block, it means that the password will not be asked when reading the repository (that is, http requests like GET
). If you want to organize a private repository, comment out this block.mercurial-common
package already has the file we need: /usr/share/doc/mercurial-common/examples/hgweb.cgi
. It needs to be copied to the /var/www/hg-public
directory and slightly corrected.<code> # mkdir / var / www / hg-public # cp /usr/share/doc/mercurial-common/examples/hgweb.cgi / var / www / hg-public / # chown -R hg: hg / var / www / hg-public # chmod + x /var/www/hg-public/hgweb.cgi </ code>
/var/www
directory and its owner / group must be hg
(remember the SuexecUserGroup hg hg
directive)./var/www/hg-public/hgweb.cgi
in a text editor and edit. Replace:<code> application = hgweb ("/ path / to / repo", "repository name") </ code>
<code> application = hgweb ("/ home / hg / repo", "Our public repo") </ code>
/path/to/repo
to /home/hg/repo
).hg-user
:<code> # su - hg $ htpasswd -c /home/hg/.hg.htpasswd hg-user </ code>
/home/hg/repo/.hg/hgrc
with the following contents:<code> [web] allow_push = hg-user push_ssl = false </ code>
hg.example.com/public
hg.example.com/public
, hg push
is executed under the name hg-user
and the password specified in the htpasswd
command. Enjoy/var/www
directory for the reason that suexec requires the scripts to be located there.Source: https://habr.com/ru/post/59243/
All Articles