title: creating subdomains with apache on debian; creating hgweb subdomain as second step
body: <p>After hours of trying to setup subdomains on my dedicated root server, I'm asking you for help.</p>
  
  <p>Target:</p>
  
  <ul>
  <li>being able to create and access subdomains</li>
  <li>setup an own subdomain for mercurial repositories, using hgweb</li>
  </ul>
  
  <p>Information about the server:</p>
  
  <ul>
  <li>Debian Linux, Kernel 2.6.32-028stab094.3</li>
  <li>Apache/2.2.16 (Debian) </li>
  <li>Mercurial 1.6.4</li>
  <li>libapache2-mod-wsgi-py3 installed</li>
  </ul>
  
  <p><strong>First question: what is wrong with my apache configuration that I can't access my subdomains via the browser?</strong></p>
  
  <p>Actually, I can access the root domain and the sites which are installed there.</p>
  
  <p>My configuration:
  <strong>/etc/apache2/sites-available/default</strong></p>
  
  <pre><code>&lt;VirtualHost *&gt;
      ServerAdmin webmaster@localhost
      ServerName mydomain.tld
      ServerAlias www.mydomain.tld
  
      DocumentRoot /var/www/forum
      &lt;Directory /&gt;
              Options FollowSymLinks
              AllowOverride None
      &lt;/Directory&gt;
      &lt;Directory /var/www/forum&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride None
              Order allow,deny
              allow from all
      &lt;/Directory&gt;
  
      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
      &lt;Directory "/usr/lib/cgi-bin"&gt;
              AllowOverride None
              Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
              Order allow,deny
              Allow from all
      &lt;/Directory&gt;
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
  
      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn
  
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
      Alias /doc/ "/usr/share/doc/"
      &lt;Directory "/usr/share/doc/"&gt;
          Options Indexes MultiViews FollowSymLinks
          AllowOverride None
          Order deny,allow
          Deny from all
          Allow from 127.0.0.0/255.0.0.0 ::1/128
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p><strong>/etc/apache2/sites-available/hgrepos.domainname.tld</strong></p>
  
  <pre><code>&lt;VirtualHost *&gt;
      ServerName hgrepos.domainname.tld
      ServerAlias www.hgrepos.domainname.tld
      DocumentRoot /var/www/hgrepos/htdocs
  
      # WSGIScriptAliasMatch ^(.*)$ /var/www/hgrepos/cgi-bin/hgweb.wsgi$1
      WSGIScriptAlias / /var/www/hgrepos/cgi-bin/hgweb.wsgi
  
      # To enable "daemon" mode, uncomment following lines. (Read mod_wsgi docs for more info)
      # WSGIDaemonProcess hgrepos.domainname.tld user=USER group=GROUP threads=1 processes=15 maximum-requests=1000
      WSGIDaemonProcess hgrepos.domainname.tld  threads=1 processes=15 maximum-requests=1000
      # some more interesting options (tested on mod_wsgi 2.0):
      # umask=0007 display-name=wsgi-hg.example.net inactivity-timeout=300
      # WSGIProcessGroup hg.example.net
  
      &lt;Directory /var/www/hgrepos/htdocs&gt;
          Options FollowSymlinks
          DirectoryIndex index.html
  
          AllowOverride None
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      &lt;Directory /var/www/hgrepos/cgi-bin&gt;
          Options ExecCGI FollowSymlinks
  
          AddHandler wsgi-script .wsgi
  
          AllowOverride None
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>My <strong>/etc/apache2/httpd.conf</strong> file is empty.</p>
  
  <p>I enabled the subdomain file via <code>a2ensite subdomain.domainname.tld</code>. </p>
  
  <pre><code>regine@diddi:/etc/apache2/sites-available# ll ../sites-enabled/
  lrwxrwxrwx 1 root root 26 Oct 29 22:33 000-default -&gt; ../sites-available/default
  lrwxrwxrwx 1 root root 48 Nov 17 00:41 hgrepos.domainname.tld -&gt; ../sites-available/hgrepos.domainname.tld
  </code></pre>
  
  <p>I used both, <code>/etc/init.d/apache2 reload</code> and <code>/etc/init.d/apache2 restart</code>. Apache didn't tell me that I tried to load a malformed configuration.</p>
  
  <p>The sites for the root domain are under <code>/var/www/forum</code> and accessible.</p>
  
  <p>My folder structure for <strong>/var/www/hgrepos</strong> looks like:</p>
  
  <pre><code>hgrepos
  +- drwxr-xr-x www-data www-data cgi-bin
  |--- -rwxr-xr-x www-data www-data hgweb.config
  |--- -rwxr-xr-x www-data www-data hgweb.wsgi
  +-- drwxr-xr-x htdocs
  |--- -rw-r--r-- www-data www-data index.html
  |--- drwxr-xr-x www-data www-data myFirstHgRep
  </code></pre>
  
  <p>The <code>index.html</code> file just contains some Hello World! html to see if the subdomain is accessible.</p>
  
  <p>So now back to my first question: why can't I access to the <strong>hgrepos</strong> subdomain via my browser?</p>
  
  <p>Now second, I want to serve some mercurial (hg) repositories for my private projects, using <code>hgweb</code>. I followed those instructions:<br>
  <a href="https://www.mercurial-scm.org/wiki/modwsgi" rel="nofollow noreferrer">https://www.mercurial-scm.org/wiki/modwsgi</a><br>
  <a href="https://www.mercurial-scm.org/wiki/HgWebDirStepByStepFtpOnly" rel="nofollow noreferrer">https://www.mercurial-scm.org/wiki/HgWebDirStepByStepFtpOnly</a></p>
  
  <p>Here are my config files under <strong>/var/www/hgrepos/cgi-bin/</strong>:</p>
  
  <p><strong>hgweb.wsgi</strong></p>
  
  <pre><code>#!/usr/bin/env python
  #
  # An example hgweb CGI script, edit as necessary
  # See also https://www.mercurial-scm.org/wiki/PublishingRepositories
  
  # Path to repo or hgweb config to serve (see 'hg help hgweb')
  # config = "hgweb.config"
  
  # Uncomment and adjust if Mercurial is not installed system-wide:
  #import sys; sys.path.insert(0, "/path/to/python/lib")
  
  # Uncomment to send python tracebacks to the browser if an error occurs:
  import cgitb; cgitb.enable()
  
  from mercurial import demandimport; demandimport.enable()
  from mercurial.hgweb import hgweb, wsgicgi
  application = hgweb("hgweb.config")
  #wsgicgi.launch(application)
  </code></pre>
  
  <p><strong>hgweb.config</strong></p>
  
  <pre><code>[web]
  style = coal
  baseurl =
  
  [paths]
  / = /var/www/hgrepos/htdocs/*
  </code></pre>
  
  <p>Rights of the files:</p>
  
  <pre><code>regine@diddi:/var/www/hgrepos/cgi-bin# ll 
  -rwxr-xr-x 1 www-data www-data  68 Nov 17 01:16 hgweb.config
  -rwxr-xr-x 1 www-data www-data 621 Nov 17 01:24 hgweb.wsgi
  </code></pre>
  
  <p><strong>So now my second question: how can I get hgweb working? What's actually wrong with my configuration?</strong></p>
  
  <p>Well, wow, this is much of text, but I'm not quite sure which information are needed and which aren't. Hope you can help me, any hint is helpful :)</p>