]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/tips/distributed_wikis.mdwn
fix link to default wiki flow
[ikiwiki.git] / doc / tips / distributed_wikis.mdwn
index 91bc1c8f275cead31dcbb46df809f7de3f9dd671..81869a94fe5311d20f1a8db61895e27a27405e08 100644 (file)
@@ -3,6 +3,55 @@ making it easy to create and maintain copies and branches of a project. And
 this can be used for all sorts of interesting stuff. Since ikiwiki can use
 git, let's explore some possibilities for distributed wikis.
 
+[[!toc levels=2]]
+
+## Overview
+
+There are three possible level of decentralisation:
+
+ 0. [[default setup|rcs/git]], no decentralisation
+ 1. [[a simple HTML mirror|tips/Git_repository_and_web_server_on_different_hosts/]]
+ 2. separate `srcdir`, still requires a central bare repo - uses [[plugin/pinger]]
+ 3. completely distinct ikiwiki installs, synchronised with
+    [[plugin/gitpush]]
+
+Here's a graphic overview of those:
+
+### Default setup - one central server
+
+[[!img rcs/git/wiki_edit_flow.svg size=490x align=center]]
+
+In the default setup, all the resources are stored on the central
+servers. Users can still clone and edit the git repo by hand and
+contribute by git, but otherwise all the changes happen on a single
+web interface.
+
+### Separate webserver and git repository
+
+[[!img tips/Git_repository_and_web_server_on_different_hosts/separate-webserver.svg align=center]]
+
+In the configuration described in
+[[tips/Git_repository_and_web_server_on_different_hosts]], the
+webserver is separate from the git repository. The webserver part
+hosts the HTML files, the ikiwiki [[cgi]] but everything else is on
+the git server.
+
+### Decentralised pinger setup
+
+[[!img ping-setup.svg align=center]]
+
+In this configuration, the mirrors all have their own `srcdir`, but
+still need to push and pull from the same central bare git repo. The
+[[plugins/pinger]] plugin is used to ping the mirrors from the central
+server on edits.
+
+### Fully decentralised setup
+
+[[!img .svg align=center]]
+
+In this configuration, each wiki is fully independent and pushes its
+changes to other wikis using the [[plugins/gitpush]] plugin.
+
 ## a wiki mirror
 
 The simplest possibility is setting up a mirror. If a wiki exposes its git
@@ -62,12 +111,10 @@ You need to install the ikiwiki package for the mirror to work. You can use ikiw
 We assume your username is `user` and that you will host the wiki under the hostname `mirror.example.com`. The original wiki is at `wiki.example.com`. We also assume that your friend was nice enough to provide a copy of the `.setup` file in the `setup` branch, which is the case for any wiki hosted on [branchable.com](http://branchable.com).
 
     cd ~user
-    # setup base repository, named source.git
-    git clone --bare git://wiki.example.com/ source.git
     # setup srcdir, named source
-    git clone source.git
+    git clone git://wiki.example.com/ source
     # convenience copy of the setup file
-    git clone -b origin/setup source.git setup
+    git clone -b origin/setup source setup
     cd setup
     edit ikiwiki.setup # adapt configuration
 
@@ -78,8 +125,8 @@ When editing ikiwiki.setup, make sure you change the following entries:
     srcdir: /home/user/source
     destdir: /var/www/mirror.example.com
     libdir: /home/user/source/.ikiwiki
-    git_wrapper: /home/user/source.git/hooks/post-commit
-    git_test_receive_wrapper: /home/user/source.git/hooks/pre-receive
+    git_wrapper: /home/user/source/.git/hooks/post-commit
+    git_test_receive_wrapper: /home/user/source/.git/hooks/pre-receive
     ENV:
       TMPDIR: /home/user/tmp
 
@@ -91,33 +138,19 @@ You should already be able to make a plain HTML rendering of the wiki:
 
     ikiwiki --setup ikiwiki.setup
 
-### Editing your copy through git
-
-At this point, your wiki should already be visible in `/var/www/mirror.example.com`, the `destdir`. You can edit it and changes should show up automatically in the `destdir`.
-
-However, you need yet another clone for this, the `srcdir` being used internally by the web interface of Ikiwiki. So clone the `repository` elsewhere:
-
-    git clone ~user/source.git checkout
-    cd checkout
-    edit index.mdwn
-    git commit index.mdwn
-    git push
-
-This will refresh the main page of the wiki, for example.
-
 ### Webserver configuration
 
 You will also need a webserver to serve the content in the `destdir`
 defined above. We assume you will configure a virtual host named `mirror.example.com`. Here are some examples on how to do those, see [[!iki setup]] and [[!iki tips/dot_cgi]] for complete documentation.
 
-Note that this will also configure CGI so that people can edit your copy of the wiki. We'll see how to sync back later.
+Note that this will also configure CGI so that people can edit the wiki. Note that this configuration may involve timeouts if the main site is down.
 
 #### Apache configuration
 
     <VirtualHost *:80>
-        ServerName reseaulibre.example.com:80
-        DocumentRoot /var/www/reseaulibre.example.com
-        <Directory /var/www/reseaulibre.example.com>
+        ServerName mirror.example.com:80
+        DocumentRoot /var/www/mirror.example.com
+        <Directory /var/www/mirror.example.com>
             Options Indexes MultiViews ExecCGI
             AllowOverride None
             Order allow,deny
@@ -130,9 +163,9 @@ Note that this will also configure CGI so that people can edit your copy of the
 #### Nginx configuration
 
     server {
-        root /var/www/reseaulibre.example.com/;
+        root /var/www/mirror.example.com/;
         index index.html index.htm;
-        server_name reseaulibre.example.com;
+        server_name mirror.example.com;
 
         location / {
             try_files $uri $uri/ /index.html;
@@ -141,7 +174,7 @@ Note that this will also configure CGI so that people can edit your copy of the
             fastcgi_pass  unix:/tmp/fcgi.socket;
             fastcgi_index ikiwiki.cgi;
             fastcgi_param SCRIPT_FILENAME   /var/www/ikiwiki.cgi;
-            fastcgi_param  DOCUMENT_ROOT      /var/www/reseaulibre.example.com;
+            fastcgi_param  DOCUMENT_ROOT      /var/www/mirror.example.com;
             include /etc/nginx/fastcgi_params;
         }
     }
@@ -168,9 +201,26 @@ Once your mirror works, you can also add it to the list of mirrors. You can ask
 
 The [[plugins/mirrorlist]] plugin of course needs to be enabled for this to work.
 
-### Pushing changes back to the main site
+### Alternative configuration
 
-The final step is to push edits on the mirror back to the master site. That way the mirror is not only for reading, but can also be edited, even when the master is offline or the network is separated.
+In the above configuration, the master git repository is still on the main site. If that site goes down, there will be delays when editing the wiki mirror. It could also simply fail because it will not be able to push the changes to the master git repo. An alternative is to setup a local bare repository that is synced with the master.
+
+At the setup step, you need to create *two* git repositories on the mirror:
+
+    cd ~user
+    # setup base repository, named source.git
+    git clone --bare git://wiki.example.com/ source.git
+    # setup srcdir, named source
+    git clone source.git
+    # convenience copy of the setup file
+    git clone -b origin/setup source.git setup
+    cd setup
+    edit ikiwiki.setup # adapt configuration
+
+The following entries will be different from the above setup file:
+
+    git_wrapper: /home/user/source.git/hooks/post-commit
+    git_test_receive_wrapper: /home/user/source.git/hooks/pre-receive
 
 To do this, the mirror needs to push back to the master, again using the gitpush plugin: