UNPKG

epubjs

Version:

Render ePub documents in the browser, across many devices

61 lines (44 loc) 3.97 kB
<?xml version='1.0' encoding='utf-8'?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Pro Git - professional version control</title> <meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/> <link href="stylesheet.css" type="text/css" rel="stylesheet"/> <style type="text/css"> @page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }</style> </head> <body class="calibre"> <h2 class="calibre4" id="calibre_pb_34">Public Access</h2> <p class="calibre3">What if you want anonymous read access to your project? Perhaps instead of hosting an internal private project, you want to host an open source project. Or maybe you have a bunch of automated build servers or continuous integration servers that change a lot, and you don't want to have to generate SSH keys all the time - you just want to add simple anonymous read access.</p> <p class="calibre3">Probably the simplest way for smaller setups is to run a static web server with its document root where your Git repositories are, and then enable that <code class="calibre10">post-update</code> hook we mentioned in the first section of this chapter. Let's work from the previous example. Say you have your repositories in the <code class="calibre10">/opt/git</code> directory, and an Apache server is running on your machine. Again, you can use any web server for this; but as an example, we'll demonstrate some basic Apache configurations that should give you an idea of what you might need.</p> <p class="calibre3">First you need to enable the hook:</p> <pre class="calibre9"><code class="calibre10">$ cd project.git $ mv hooks/post-update.sample hooks/post-update $ chmod a+x hooks/post-update </code></pre> <p class="calibre3">If you're using a version of Git earlier than 1.6, the <code class="calibre10">mv</code> command isn't necessary - Git started naming the hooks examples with the .sample postfix only recently. </p> <p class="calibre3">What does this <code class="calibre10">post-update</code> hook do? It looks basically like this:</p> <pre class="calibre9"><code class="calibre10">$ cat .git/hooks/post-update #!/bin/sh exec git-update-server-info </code></pre> <p class="calibre3">This means that when you push to the server via SSH, Git will run this command to update the files needed for HTTP fetching.</p> <p class="calibre3">Next, you need to add a VirtualHost entry to your Apache configuration with the document root as the root directory of your Git projects. Here, we're assuming that you have wildcard DNS set up to send <code class="calibre10">*.gitserver</code> to whatever box you're using to run all this:</p> <pre class="calibre9"><code class="calibre10">&lt;VirtualHost *:80&gt; ServerName git.gitserver DocumentRoot /opt/git &lt;Directory /opt/git/&gt; Order allow, deny allow from all &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p class="calibre3">You'll also need to set the Unix user group of the <code class="calibre10">/opt/git</code> directories to <code class="calibre10">www-data</code> so your web server can read-access the repositories, because the Apache instance running the CGI script will (by default) be running as that user:</p> <pre class="calibre9"><code class="calibre10">$ chgrp -R www-data /opt/git </code></pre> <p class="calibre3">When you restart Apache, you should be able to clone your repositories under that directory by specifying the URL for your project:</p> <pre class="calibre9"><code class="calibre10">$ git clone http://git.gitserver/project.git </code></pre> <p class="calibre3">This way, you can set up HTTP-based read access to any of your projects for a fair number of users in a few minutes. Another simple option for public unauthenticated access is to start a Git daemon, although that requires you to daemonize the process - we'll cover this option in the next section, if you prefer that route.</p> </body> </html>