Setting Up git-http-backend with apache 2.4
<p>Im trying to set up a git server using git-http-backend and apache 2.4  I found <a href="https://stackoverflow.com/questions/26734933/how-to-set-up-git-over-http">this question</a> about the same thing which was helpful, but I'm still reaching a point where I'm stuck.</p>

<p>I've installed git and apache2 on Ubuntu 16.04 and added the needed modules using</p>

<p><code>sudo a2enmod cgi alias env</code></p>

<p>Then added the following snippet in <code>/etc/apache2/apache2.conf</code> :</p>

<pre><code>&lt;VirtualHost *:80&gt;
    SetEnv GIT_PROJECT_ROOT /var/www/git
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
    ScriptAliasMatch \
      "(?x)^/(.*/(HEAD | \
          info/refs | \
          objects/(info/[^/]+ | \
          [0-9a-f]{2}/[0-9a-f]{38} | \
          pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
          git-(upload|receive)-pack))$" \
      "/usr/lib/git-core/git-http-backend/$1"
    Alias /git /var/www/git
    &lt;Directory /usr/lib/git-core&gt;
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AllowOverride None
        Require all granted
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</code></pre>

<p>Note that <code>/var/www/git</code> is where I intend my repos to go, and running </p>

<p><code>find / -name git-http-backend</code> shows <code>/usr/lib/git-core/git-http-backend</code></p>

<p>Next, inside of <code>/var/www/git/</code> I created a directory <code>myrepo.git</code> and set it up as such:</p>

<pre><code>sudo git init --bare --shared
sudo cp hooks/post-update.sample hooks/post-update
sudo git update-server-info
</code></pre>

<p>Next, I have to change the ownership of the directory to the apache2 owner (Im told).  Running <code>ps aux | egrep '(apache|httpd)'</code> returns the following:</p>

<pre><code>root 3087 0.0 0.4 73688  4928 ? Ss 02:37 0:00 /usr/sbin/apache2 -k start
www-data 3455 0.0 0.5 362836  5852 ? Sl 03:13 0:00 /usr/sbin/apache2 -k start
www-data 3456 0.0 0.5 362836  5852 ? Sl 03:13 0:00 /usr/sbin/apache2 -k start
git 3531 0.0 0.0 14512 932 pts/1 S+ 03:19 0:00 grep -E --color=auto (apache|httpd)
</code></pre>

<p>Now I'm not sure, because it looks like both <code>root</code> and <code>www-data</code> are running something, but I have currently decided to set the ownership to www-data (maybe it should be root?).  www-data's group is also www-data (I think)</p>

<pre><code>$ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
</code></pre>

<p>so I use that to set ownership:</p>

<pre><code>sudo chown -R www-data:www-data .
</code></pre>

<p>I also seem to remember reading that the whole path has to belong to the apache user so just for good measure I set</p>

<pre><code>sudo chown -R www-data:www-data /var/www
</code></pre>

<p>Now from my localmachine I am trying to clone the myrepo:</p>

<pre><code>git clone http://&lt;ip-address&gt;/myrepo.git
</code></pre>

<p>And I am getting the error:</p>

<pre><code>fatal: unable to access 'http://&lt;ip-address&gt;/myrepo.git/': The requested URL returned error: 503
</code></pre>

<p>Can anybody see what Im doing wrong?</p>