Table of Contents

Suppose you are running your laptop without Internet connection, but somehow still want to look up a specific topic in Wikipedia. For Linux users, one way to work around is to set up a local server using kiwix-serve to serve offline contents. Here are the steps. Note that Internet is required to download the program and associated ZIM files.

screenshot of kiwix

Step 1 Download kiwix-tools

You can use pre-built binaries or compile from source.

curl -L https://download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-x86_64-3.1.2.tar.gz | tar -xz

For information on manual compilation, please visit official Github repository.

Step 2 Download ZIM files

The full list can be found here. Feel free to choose topics you need in various languages. Below is a simple example.

curl -LO http://download.kiwix.org/zim/wikipedia/wikipedia_en_computer_maxi_2020-08.zim

Step 3 Create a dedicated user and move all downloaded files to the user’s home directory

export KIWIX_PREFIX=/opt/kiwix
useradd -d $KIWIX_PREFIX -Mrs /sbin/nologin kiwix
mkdir -p $KIWIX_PREFIX/{bin,data}
mv kiwix-tools_linux-x86_64-3.1.2/* bin
mv *.zim data

Step 4 Generate a list for all ZIM files

$KIWIX_PREFIX/bin/kiwix-manage $KIWIX_PREFIX/data/library.xml add $KIWIX_PREFIX/data/*.zim

Step 5 Run the program

sudo -u kiwix $KIWIX_PREFIX/bin/kiwix-serve \
    --library $KIWIX_PREFIX/data/library.xml \
    --address 127.0.0.1 --port 8080

Note that port under 1024 requires root access. More options are available via $KIWIX_PREFIX/bin/kiwix-serve --help.

Now go to 127.0.0.1:8080 and enjoy your offline wiki!


Here is a minimal template for systemd if the program should be launched at startup:

[Unit]
Description=Kiwix

[Service]
Type=simple
User=kiwix
ExecStart=/opt/kiwix/bin/kiwix-serve --library /opt/kiwix/data/library.xml --address 127.0.0.1 --port 8080 --daemon
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target