{"thread":{"id":"5200","subject":"[PATCH] Add Documentation/howto/setup-git-server-over-http.txt","startedAt":"2006-08-10T20:00:26Z","lastAt":"2006-08-10T20:00:26Z","messageCount":1,"participants":["Rutger Nijlunsing"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25112","messageId":"20060810200026.GA20120@nospam.com","threadId":"5200","inReplyTo":null,"subject":"[PATCH] Add Documentation/howto/setup-git-server-over-http.txt","fromName":"Rutger Nijlunsing","fromEmail":"rutger@nospam.com","sentAt":"2006-08-10T20:00:26Z","receivedAt":"2006-08-10T20:00:26Z","isPatch":true,"sender":{"key":"rutger.nijlunsing@gmail.com","avatar":null},"body":"A small howto on how to setup GIT over HTTP transport protocol by\nsetting up WebDAV access on apache2.\n\nSigned-off-by: Rutger Nijlunsing <git@tux.tmfweb.nl>\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n Documentation/howto/setup-git-server-over-http.txt |  255 ++++++++++++++++++++\n 1 files changed, 255 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt\nnew file mode 100644\nindex 0000000..7279674\n--- /dev/null\n+++ b/Documentation/howto/setup-git-server-over-http.txt\n@@ -0,0 +1,255 @@\n+HOWTO: Setting up a git repository which can be pushed into and pulled\n+from over HTTP.\n+\n+Since Apache is one of those packages people like to compile\n+themselves while others prefer the bureaucrat's dream Debian, it is\n+impossible to give guideliness which will work for everyone. Just send\n+some feedback to the mailinglist at git@vger.kernel.org to get this\n+document tailored to your favorit distro.\n+\n+\n+What's needed:\n+\n+- Have an Apache webserver\n+\n+  On Debian:\n+    $ apt-get install apache2\n+    To get apache2 by default started,\n+    edit /etc/default/apache2 and set NO_START=0\n+\n+- can edit the configuration of it.\n+\n+  This could be found under /etc/httpd, or refer to your Apache documentation.\n+\n+  On Debian: this means being able to edit files under /etc/apache2\n+\n+- can restart it.\n+\n+  'apachectl --graceful' might do. If it doesn't, just stop and\n+  restart apache. Be warning that active connections to your server\n+  might be aborted by this.\n+\n+  On Debian:\n+    $ /etc/init.d/apache2 restart\n+  or\n+    $ /etc/init.d/apache2 force-reload\n+    (which seems to do the same)\n+  This adds symlinks from the /etc/apache2/mods-enabled to\n+  /etc/apache2/mods-available.\n+\n+- have permissions to chown a directory\n+\n+- have git installed at the server _and_ client\n+\n+In effect, this probably means you're going to be root.\n+\n+\n+Step 1: setup a bare GIT repository\n+-----------------------------------\n+\n+At the time of writing, git-http-push cannot remotely create a GIT\n+repository. So we have to do that at the server side with git. Another\n+option would be to generate an empty repository at the client and copy\n+it to the server with WebDAV. But then you're probably the first to\n+try that out :)\n+\n+Create the directory under the DocumentRoot of the direcories served\n+by Apache. As an example we take /usr/local/apache2, but try \"grep\n+DocumentRoot /where/ever/httpd.conf\" to find your root:\n+\n+    $ cd /usr/local/apache/htdocs\n+    $ mkdir my-new-repo.git\n+\n+  On Debian:\n+\n+    $ cd /var/www\n+    $ mkdir my-new-repo.git\n+\n+\n+Initialize a bare repository\n+ \n+    $ cd my-new-repo.git\n+    $ git --bare init-db\n+\n+\n+Change the ownership to your webserver's credentials. Use \"grep ^User\n+httpd.conf\" and \"grep ^Group httpd.conf\" to find out:\n+ \n+    $ chown -R www.www .\n+\n+  On Debian:\n+\n+    $ chown -R www-data.www-data .\n+\n+\n+If you do not know which user Apache runs as, you can alternatively do\n+a \"chmod -R a+w .\", inspect the files which are created later on, and\n+set the permissions appropriately.\n+\n+Restart apache2, and check whether http://server/my-new-repo.git gives\n+a directory listing. If not, check whether apache started up\n+succesfully.\n+\n+\n+Step 2: enable DAV on this repository\n+-------------------------------------\n+\n+First make sure the dav module is loaded. For this, insert in httpd.conf:\n+\n+    LoadModule dav_module libexec/httpd/libdav.so\n+    AddModule mod_dav.c\n+\n+Also make sure that this line exists which is the file used for\n+locking DAV operations:\n+\n+  DAVLockDB \"/usr/local/apache2/temp/DAV.lock\"\n+\n+  On Debian these steps can be performed with:\n+\n+    Enable the dav and dav_fs modules of apache:\n+    $ a2enmod dav_fs\n+    (just to be sure. dav_fs might be unneeded, I don't know)\n+    $ a2enmod dav\n+    The DAV lock is located in /etc/apache2/mods-available/dav_fs.conf:\n+      DAVLockDB /var/lock/apache2/DAVLock\n+\n+Of course, it can point somewhere else, but the string is actually just a \n+prefix in some Apache configurations, and therefore the _directory_ has to \n+be writable by the user Apache runs as.\n+\n+Then, add something like this to your httpd.conf\n+\n+  <Location /my-new-repo.git>\n+     DAV on\n+     AuthType Basic\n+     AuthName \"Git\"\n+     AuthUserFile /usr/local/apache2/conf/passwd.git\n+     Require valid-user\n+  </Location>\n+\n+  On Debian:\n+    Create (or add to) /etc/apache2/conf.d/git.conf :\n+\n+    <Location /my-new-repo.git>\n+       DAV on\n+       AuthType Basic\n+       AuthName \"Git\"\n+       AuthUserFile /etc/apache2/passwd.git\n+       Require valid-user\n+    </Location>\n+\n+    Debian automatically reads all files under /etc/apach2/conf.d.\n+\n+The password file can be somewhere else, but it has to be readable by\n+Apache and preferably not readable by the world.\n+\n+Create this file by\n+    $ htpasswd -c /usr/local/apache2/conf/passwd.git <user>\n+\n+    On Debian:\n+      $ htpasswd -c /etc/apache2/passwd.git <user>\n+\n+You will be asked a password, and the file is created. Subsequent calls\n+to htpasswd should omit the '-c' option, since you want to append to the\n+existing file.\n+\n+You need to restart Apache.\n+\n+Now go to http://<username>@<servername>/my-new-repo.git in your\n+browser to check whether it asks for a password and accepts the right\n+password.\n+\n+On Debian:\n+\n+   To test the WebDAV part, do:\n+\n+   $ apt-get install litmus\n+   $ litmus http://<servername>/my-new-repo.git <username> <password>\n+\n+   Mosts tests should pass.\n+\n+A command line tool to test WebDAV is cadaver.\n+\n+If you're into Windows, from XP onwards Internet Explorer supports\n+WebDAV. For this, do Internet Explorer -> Open Location ->\n+http://<servername>/my-new-repo.git [x] Open as webfolder -> login .\n+\n+\n+Step 3: setup the client\n+------------------------\n+ \n+Make sure that you have HTTP support, i.e. your git was built with curl.\n+The easiest way to check is to look for the executable 'git-http-push'.\n+\n+Then, add the following to your $HOME/.netrc (you can do without, but will be\n+asked to input your password a _lot_ of times):\n+\n+    machine <servername>\n+    login <username>\n+    password <password>\n+\n+...and set permissions:\n+     chmod 600 ~/.netrc\n+\n+If you want to access the webserver by its IP, you have to type that in,\n+instead of the server name.\n+\n+To check whether all is OK, do:\n+\n+   curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/\n+\n+...this should give a directory listing in HTML of /var/www/my-new-repo.git .\n+\n+\n+Now, add the remote in your existing repository which contains the project\n+you want to export:\n+ \n+   $ git-repo-config remote.upload.url \\\n+       http://<username>@<servername>/my-new-repo.git/\n+\n+It is important to put the last '/'; Without it, the server will send\n+a redirect which git-http-push does not (yet) understand, and git-http-push\n+will repeat the request inifinitely.\n+\n+\n+Step 4: make the initial push\n+-----------------------------\n+\n+From your client repository, do\n+\n+   $ git push upload master\n+\n+This pushes branch 'master' (which is assumed to be the branch you\n+want to export) to repository called 'upload', which we previously\n+defined with git-repo-config.\n+\n+\n+Troubleshooting:\n+----------------\n+\n+If git-http-push says\n+\n+   Error: no DAV locking support on remote repo http://...\n+\n+then it means the webserver did not accept your authentication. Make sure\n+that the user name and password matches in httpd.conf, .netrc and the URL\n+you are uploading to.\n+\n+If git-http-push shows you an error (22/502) when trying to MOVE a blob,\n+it means that your webserver somehow does not recognize its name in the\n+request; This can happen when you start Apache, but then disable the\n+network interface. A simple restart of Apache helps.\n+\n+Errors like (22/502) are of format (curl error code/http error\n+code). So (22/404) means something like 'not found' at the server.\n+\n+Reading /usr/local/apache2/logs/error_log is often helpful.\n+\n+  On Debian: Read /var/log/apache2/error.log instead.\n+\n+\n+Debian References: http://www.debian-administration.org/articles/285\n+\n+Authors\n+  Johannes Schindelin <Johannes.Schindelin@gmx.de>\n+  Rutger Nijlunsing <git@wingding.demon.nl>\n-- \n1.4.2.rc2.g7cb1\n\n-- \nRutger Nijlunsing ---------------------------------- eludias ed dse.nl\nnever attribute to a conspiracy which can be explained by incompetence\n----------------------------------------------------------------------\n"}]}