Self-Hosting a Copy of Wikipedia with Kiwix
I’m not sure anymore where I got the idea from, but I recently thought it would be nice to host a local copy of Wikipedia.
Luckily, there’s a project exactly for that: Kiwix. It’s extremely simple to get running with Debian, just install it and download a zim file for Wikipedia.
apt-get install kiwix-tools
wget https://download.kiwix.org/zim/wikipedia/wikipedia_en_all_mini_2024-04.zim
Then run kiwix-serve
and point it to the zim file:
kiwix-serve --port 8080 wikipedia_en_all_mini_2024-04.zim
Unfortunately, I don’t see an option to listen to a Unix socket instead of a port. I always prefer the socket option, because the ingress goes through a reverse-proxy, anyway.
Systemd
kiwix-tools
doesn’t seem to come with a systemd unit, so let’s create one
to automatically start it.
[Unit]
Description=Kiwix Serve
After=network.target network-online.target
[Service]
User=skoch
ExecStart=kiwix-serve --port 8080 /home/skoch/wikipedia_en_all_mini_2024-04.zim
Type=simple
[Install]
WantedBy=multi-user.target
Nginx
To reach Kiwix under the /kiwix
path on my home server, I’ve set a forward
in nginx like this:
location /kiwix {
proxy_pass http://127.0.0.1:8080/kiwix;
}
I had to pass the additional flag --urlRootLocation /kiwix
to Kiwix.
Additionally, I’ve limited Kiwix to localhost with --address 127.0.0.1
.