This blog software is awesome, I welcome my new cult overload. Here is how I did it;

apt-get install ikiwiki git-core nginx

Then make a new user and path for the wiki owner

useradd ikiwiki
mkdir /var/www/blog
adduser ikiwiki
chown ikiwiki /var/www/blog

Set up the user for SSH login

mkdir ~ikiwiki/.ssh
ssh-add -L > ~ikiwiki/.ssh/authorized_keys
chown -R ikiwiki ~ikiwiki/.ssh
chown -R og-rwX ~ikiwiki/.ssh

Then you can ssh to the ikiwiki user on your server host and run the basic setup.

ssh ikiwiki@myhost.com
ikiwiki --setup /etc/ikiwiki/auto-blog.setup

… insert a montage of mucking around, editing config files, etc …

vi myblog.setup

ikiwiki -setup myblog.setup


I got to this nginx configuration (/etc/nginx/sites-available.d/blog):

server {
   listen   80; ## listen for ipv4
   server_name  myblog.com;
   access_log  /var/log/nginx/blog.log;
   location / {
        root   /var/www/blog/docs;
        index  index.html index.htm;

        # I use this little redirector script for an easy, client-side JS redirect
        rewrite ^/blog/(20../.*.html)$ /redirector.html?$1 last;
   error_page  404  /404.html;
   #error_page   403 500 502 503 504  /err/50x.html;
   #location = /50x.html {
   #       root   /var/www/nginx-default;
   location = /ikiwiki.cgi {
        fastcgi_pass   /var/run/fcgiwrap.socket;
        fastcgi_index  ikiwiki.cgi;
        fastcgi_param  QUERY_STRING       $query_string;
        fastcgi_param  REQUEST_METHOD     $request_method;
        fastcgi_param  CONTENT_TYPE       $content_type;
        fastcgi_param  CONTENT_LENGTH     $content_length;
        fastcgi_param  SCRIPT_NAME        ../cgi-bin/ikiwiki.cgi;
        fastcgi_param  REQUEST_URI        $request_uri;
        fastcgi_param  DOCUMENT_URI       $document_uri;
        fastcgi_param  DOCUMENT_ROOT      /var/www/blog/docs/;
        fastcgi_param  SERVER_PROTOCOL    $server_protocol;
        fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
        fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
        fastcgi_param  REMOTE_ADDR        $remote_addr;
        fastcgi_param  REMOTE_PORT        $remote_port;
        fastcgi_param  SERVER_ADDR        $server_addr;
        fastcgi_param  SERVER_PORT        $server_port;
        fastcgi_param  SERVER_NAME        $server_name;

The SCRIPT_NAME must match what you pass to “cgi_wrapper” in the .setup file configuration.

Activate and restart nginx to get it to pick it up:

cd /etc/nginx/sites-enabled.d
ln -s ../sites-available.d/blog .
sudo /etc/init.d/nginx restart

I had to enable quite a few plugins, like “lockedit html date” which were very useful.

I added an /etc/inittab entry for spawn-fcgi:

iki:4:respawn:/bin/su ikiwiki /usr/bin/spawn-fcgi -s /tmp/fcgi.socket -n -- /usr/sbin/fcgiwrap

(And run ‘init q’): Also,

Then, my blog started to work. I could clone my remote repo

git clone ikiwiki@myblog.com:myblog

I find to my delight that I now have a CGI form for adding posts (old school! :-)) and that I can also add them via a text edit and publish via:

git push

Compared to my old wiki scripts, this is much more slick!

I also found it all very difficult until I found the locally installed ikiwiki documentation and got familiar with it. Very useful!

Also useful was this post-commit hook:


# if uncommitted changes, don't do anything yet
if [ -z "$(git ls-files -d -m -u --exclude-standard| tail -1)" ]
    branch=$(git symbolic-ref HEAD)
    branch=$(expr "$branch" : 'refs/heads/\(.*\)')
    [ -n "$branch" ] || exit 0;
    [ -n "$(git config -l branch.$branch.merge)" ] || exit 0;
    echo -n "Pull from upstream: "
    git pull --rebase

This meant that I was always making a linear history.

Share Comments
comments powered by Disqus