Do you have a need to host Wikipedia on your computer?

Or a StackExchange site, like Super User?

It’s easier than you think!

image

Step 1: download stuff!

The Kiwix project provides ZIM files for many popular websites, including Wikipedia. These files can be downloaded over at Kiwix wiki.

Take a look at the content packages available and download those that you are interested in.

Step 2: install Kiwix

Kiwix provides all sorts of clients for different operating systems. If you don’t want to go crazy with setting up a server and you just want to browser your offline copy of Wikipedia or any other resource, then go ahead and use that.

However, if you want to make the resources available for other people as well, then you need to install kiwix-serve. On Debian and Ubuntu systems, this is just a sudo apt install kiwix-tools in your terminal.

Once you have it installed, all you have to do is to run kiwix-serve -p 8080 your-file-here.zim and your content package is served to anyone who can connect to your machine with a browser over port 8080.

If you have multiple ZIM files in the same folder, then you can serve all of them at once with something like kiwix-serve -p 8080 *.zim.

Step 3: enjoy!

You should now be up and running with your very own hosted Wikipedia instance! Just keep in mind that your copy might not be 100% up to date. The Kiwix project does repackage these sites quite regularly so keep an eye out for updates.

If you don’t have the time to set this up yourself, but want to give it a go, then try my own hosted Kiwix instance. Do note that my uplink is quite limited so it might load a bit slowly if there’s a lot of traffic here.

Tips and tricks

I have set up my own Kiwix instance and the way it works is quite simple.

I use Deluge to download and seed the content packs that I have downloaded.

Then I have also set up a systemd service that automatically starts Kiwix on boot. It is located at /etc/systemd/system/kiwix-serve.service and looks like this:

[Unit]
Description=Serve all the ZIM files loaded on this server

[Service]
Restart=always
RestartSec=15
User=kiwix
ExecStart=/usr/bin/bash -c "/usr/bin/kiwix-serve -p 8080 /path/to/your/files/*.zim"

[Install]
WantedBy=network-online.target

Note that I have set up a separate non-interactive user for this purpose. The path to the ZIM files simply refers to the download folder of the Deluge torrent client.

Making this available to the world is simply a matter of either exposing the selected port to the world, or using nginx as a reverse proxy. There are plenty of guides available on how to achieve the latter so I won’t go into detail about that here.

That’s it!