title: Structuring a central Git remote to serve production Apache sites
body: <p>I've been referring to <a href="http://toroid.org/ams/git-website-howto" rel="nofollow noreferrer">http://toroid.org/ams/git-website-howto</a> as a starting point for a production web server running on a managed VPS. The VPS runs cPanel and WHM, and it will eventually host multiple client websites, each with its own cPanel account (thus, each with its own Linux user and home directory from which sites are served). Each client's site is a separate Git repository.</p>
  
  <p>Currently, I'm pushing each repository via SSH to a bare repo in the client's home folder, e.g. <code>/home/username/git/repository.git/</code>. As per the tutorial above, each repo has been configured to checkout to another directory via a post-receive hook. In this case, each repo checks out to its own <code>/home/username/public_html</code> (the default DocumentRoot for new cPanel accounts), where the files are then served by Apache. While this works, it requires me to set up (in my local development environment) my remotes like this:</p>
  
  <pre><code>url = ssh://username@example.com/home/username/git/repository.git/
  </code></pre>
  
  <p>It also requires me to enter the user's password every time I push to it, which is less than ideal.</p>
  
  <p>In an attempt to centralize all of my repositories in one folder, I also tried pushing to <code>/root/git/repository.git</code> as root and then checking out to the appropriate home directory from there. However, this causes all of the checked-out files to be owned by root, which prevents Apache from serving the site, with errors like</p>
  
  <pre><code>[error] [client xx.xx.xx.xx] SoftException in Application.cpp:357: UID of script "/home/username/public_html/index.php" is smaller than min_uid
  </code></pre>
  
  <p>(which is a file ownership/permissions issue, as far as I can tell)</p>
  
  <p>I can solve <strong>that</strong> problem with chown and chgrp commands in each repo's post-receive hook--however, that also raises the "not quite right" flag in my head. I've also considered gitosis (to centralize all my repos in <code>/home/git/</code>), but I assume that I'd run into the same file ownership problem, since the checked-out files would then be owned by the git user.</p>
  
  <p>Am I just approaching this entire thing the wrong way? I feel like I'm completely missing a third, more elegant solution to the overall problem. Or should I just stick to one of the methods I described above?</p>