]> sipb.mit.edu Git - ikiwiki.git/commitdiff
add a practical example on how to do a mirror
authorhttps://id.koumbit.net/anarcat <https://id.koumbit.net/anarcat@web>
Fri, 6 Sep 2013 02:03:20 +0000 (22:03 -0400)
committeradmin <admin@branchable.com>
Fri, 6 Sep 2013 02:03:20 +0000 (22:03 -0400)
doc/tips/distributed_wikis.mdwn

index cf9c2e338a1311e83797a37d7b6f7ec96b5dd342..91bc1c8f275cead31dcbb46df809f7de3f9dd671 100644 (file)
@@ -44,3 +44,145 @@ the wiki, and if you could even resolve the conflict using the web
 interface. Not 100% sure as I've not gotten into this situation yet.
 
 --[[Joey]]
+
+## Practical example
+
+Say you have a friend that has already configured a shiny ikiwiki site, and you want to help by creating a mirror. You still need to figure out how to install ikiwiki and everything, hopefully this section will help you with that.
+
+### Installing ikiwiki
+
+You need to install the ikiwiki package for the mirror to work. You can use ikiwiki to publish the actual HTML pages elsewhere if you don't plan on letting people edit the wiki, but generally you want the package to be installed on the webserver for editing to work.
+
+    apt-get install ikiwiki
+
+### Setting up the wiki
+
+(!) Optionnally: create a user just for this wiki. Otherwise the wiki will run as your user from here on.
+
+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
+    # convenience copy of the setup file
+    git clone -b origin/setup source.git setup
+    cd setup
+    edit ikiwiki.setup # adapt configuration
+
+When editing ikiwiki.setup, make sure you change the following entries:
+
+    cgiurl: http://mirror.example.com/ikiwiki.cgi
+    cgi_wrapper: /var/www/ikiwiki.cgi
+    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
+    ENV:
+      TMPDIR: /home/user/tmp
+
+This assumes that your /var/www directory is writable by your user.
+
+### Basic HTML rendering
+
+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.
+
+#### Apache configuration
+
+    <VirtualHost *:80>
+        ServerName reseaulibre.example.com:80
+        DocumentRoot /var/www/reseaulibre.example.com
+        <Directory /var/www/reseaulibre.example.com>
+            Options Indexes MultiViews ExecCGI
+            AllowOverride None
+            Order allow,deny
+            allow from all
+        </Directory>
+        ScriptAlias /ikiwiki.cgi /var/www/ikiwiki.cgi
+        ErrorDocument 404 "/ikiwiki.cgi"
+    </VirtualHost>
+
+#### Nginx configuration
+
+    server {
+        root /var/www/reseaulibre.example.com/;
+        index index.html index.htm;
+        server_name reseaulibre.example.com;
+
+        location / {
+            try_files $uri $uri/ /index.html;
+        }
+        location /ikiwiki.cgi {
+            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;
+            include /etc/nginx/fastcgi_params;
+        }
+    }
+
+Start this process as your own user (or the user that has write access
+to `srcdir`, `destdir`, etc):
+
+    spawn-fcgi -s /tmp/fcgi.socket -n -- /usr/sbin/fcgiwrap
+
+Make this writable:
+
+    chmod a+w /tmp/fcgi.socket
+
+### Read-only mirror: done!
+
+At this point, you are done! You can edit your own clone of the wiki, although your changes will not go back to the main site. However, you can always push or pull manually from the `repository` in `~user/source.git` to update the main site.
+
+### Announcing the mirror
+
+Once your mirror works, you can also add it to the list of mirrors. You can ask the mirror where you take it from (and why not, all mirrors) to add it to their setup file. As an example, here's the configuration for the first mirror:
+
+    mirrorlist:
+      example: https://wiki.example.com/
+
+The [[plugins/mirrorlist]] plugin of course needs to be enabled for this to work.
+
+### Pushing changes back to the main site
+
+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.
+
+To do this, the mirror needs to push back to the master, again using the gitpush plugin:
+
+    git_push_to:
+    - git://wiki.example.com/
+
+This will ensure that commits done on the mirror will propagate back to the master.
+
+### Other guides
+
+Another guide is the [[tips/laptop_wiki_with_git]] guide. To get a
+better understanding of how ikiwiki works, see [[rcs/git]].
+
+[This](http://piny.be/jrayhawk/notes/ikiwiki_creation/) may also be of
+use if the above doesn't work.