1 [[rcs/git]] and other distributed version control systems are all about
2 making it easy to create and maintain copies and branches of a project. And
3 this can be used for all sorts of interesting stuff. Since ikiwiki can use
4 git, let's explore some possibilities for distributed wikis.
10 The simplest possibility is setting up a mirror. If a wiki exposes its git
11 repository and has the [[plugins/pinger]] plugin enabled, then anyone can
12 set up a mirror that will automatically be kept up-to-date with the origin
13 wiki. Just clone the git repo, configure ikiwiki to use it, enable the
14 [[plugins/pingee]] plugin in your configuration, and edit the origin wiki,
15 adding a ping directive for your mirror:
17 \[[!ping from="http://thewiki.com/"
18 to="http://mymirror.com/ikiwiki.cgi?do=ping"]]
20 The "from" parameter needs to be the url to the origin wiki. The "to" parameter
21 is the url to ping on your mirror.
23 Now whenever the main wiki is edited, it will ping your mirror, which will
24 pull the changes from "origin" using git, and update itself. It could, in
25 turn ping another mirror, etc.
27 And if someone edits a page on your mirror, it will "git push origin",
28 committing the changes back to the origin git repository, and updating the
29 origin mirror. Assuming you can push to that git repository. If you can't,
30 and you want a mirror, and not a branch, you should disable web edits on
31 your mirror. (You could also point the cgiurl for your mirror at the origin
36 It follows that setting up a branch of a wiki is just like a mirror, except
37 we don't want it to push changes back to the origin. The easy way to
38 accomplish this is to clone the origin git repository using a readonly
39 protocol (ie, "git://"). Then you can't push to it.
41 If a page on your branch is modified and other modifications are made to
42 the same page in the origin, a conflict might occur when that change is
43 pulled in. How well will this be dealt with and how to resolve it? I think
44 that the conflict markers will just appear on the page as it's rendered in
45 the wiki, and if you could even resolve the conflict using the web
46 interface. Not 100% sure as I've not gotten into this situation yet.
52 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.
54 ### Installing ikiwiki
56 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.
58 apt-get install ikiwiki
60 ### Setting up the wiki
62 (!) Optionnally: create a user just for this wiki. Otherwise the wiki will run as your user from here on.
64 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).
67 # setup srcdir, named source
68 git clone git://wiki.example.com/ source
69 # convenience copy of the setup file
70 git clone -b origin/setup source setup
72 edit ikiwiki.setup # adapt configuration
74 When editing ikiwiki.setup, make sure you change the following entries:
76 cgiurl: http://mirror.example.com/ikiwiki.cgi
77 cgi_wrapper: /var/www/ikiwiki.cgi
78 srcdir: /home/user/source
79 destdir: /var/www/mirror.example.com
80 libdir: /home/user/source/.ikiwiki
81 git_wrapper: /home/user/source/.git/hooks/post-commit
82 git_test_receive_wrapper: /home/user/source/.git/hooks/pre-receive
84 TMPDIR: /home/user/tmp
86 This assumes that your /var/www directory is writable by your user.
88 ### Basic HTML rendering
90 You should already be able to make a plain HTML rendering of the wiki:
92 ikiwiki --setup ikiwiki.setup
94 ### Webserver configuration
96 You will also need a webserver to serve the content in the `destdir`
97 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.
99 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.
101 #### Apache configuration
104 ServerName mirror.example.com:80
105 DocumentRoot /var/www/mirror.example.com
106 <Directory /var/www/mirror.example.com>
107 Options Indexes MultiViews ExecCGI
112 ScriptAlias /ikiwiki.cgi /var/www/ikiwiki.cgi
113 ErrorDocument 404 "/ikiwiki.cgi"
116 #### Nginx configuration
119 root /var/www/mirror.example.com/;
120 index index.html index.htm;
121 server_name mirror.example.com;
124 try_files $uri $uri/ /index.html;
126 location /ikiwiki.cgi {
127 fastcgi_pass unix:/tmp/fcgi.socket;
128 fastcgi_index ikiwiki.cgi;
129 fastcgi_param SCRIPT_FILENAME /var/www/ikiwiki.cgi;
130 fastcgi_param DOCUMENT_ROOT /var/www/mirror.example.com;
131 include /etc/nginx/fastcgi_params;
135 Start this process as your own user (or the user that has write access
136 to `srcdir`, `destdir`, etc):
138 spawn-fcgi -s /tmp/fcgi.socket -n -- /usr/sbin/fcgiwrap
142 chmod a+w /tmp/fcgi.socket
144 ### Read-only mirror: done!
146 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.
148 ### Announcing the mirror
150 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:
153 example: https://wiki.example.com/
155 The [[plugins/mirrorlist]] plugin of course needs to be enabled for this to work.
157 ### Alternative configuration
159 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.
161 At the setup step, you need to create *two* git repositories on the mirror:
164 # setup base repository, named source.git
165 git clone --bare git://wiki.example.com/ source.git
166 # setup srcdir, named source
168 # convenience copy of the setup file
169 git clone -b origin/setup source.git setup
171 edit ikiwiki.setup # adapt configuration
173 The following entries will be different from the above setup file:
175 git_wrapper: /home/user/source.git/hooks/post-commit
176 git_test_receive_wrapper: /home/user/source.git/hooks/pre-receive
178 To do this, the mirror needs to push back to the master, again using the gitpush plugin:
181 - git://wiki.example.com/
183 This will ensure that commits done on the mirror will propagate back to the master.
187 Another guide is the [[tips/laptop_wiki_with_git]] guide. To get a
188 better understanding of how ikiwiki works, see [[rcs/git]].
190 [This](http://piny.be/jrayhawk/notes/ikiwiki_creation/) may also be of
191 use if the above doesn't work.