Latest way to install Kiwix on Raspberry Pi. (It works with Pi Zero 2 W)
Kiwix allows you to access offline copies of websites like Wikipedia. This guide will walk you through installing and setting up Kiwix on your Raspberry Pi.
Before starting, make sure:
- You have a Raspberry Pi with Raspberry Pi OS installed.
- You have an active internet connection.
- You are logged in as a user with
sudo
privileges. - My user is
admin
, if yours is different please change it in the below scrips.
First, ensure your system is up to date:
sudo apt update -y && sudo apt upgrade -y
Install the Kiwix Tools package:
sudo apt install kiwix-tools -y
-
Create a directory to store your library:
sudo mkdir /home/admin/kiwix-library
-
Create an empty
library.xml
file:sudo touch /home/admin/kiwix-library/library.xml
-
Open the file for editing:
sudo nano /home/admin/kiwix-library/library.xml
-
Add the following content and save the file:
<?xml version="1.0" encoding="UTF-8"?> <library xmlns="http://www.kiwix.org/"> </library>
Download a sample ZIM file to your library directory:
sudo wget -O /home/admin/kiwix-library/medlineplus.gov_en_all_2025-01.zim https://download.kiwix.org/zim/zimit/medlineplus.gov_en_all_2025-01.zim
Add the downloaded ZIM file to your library.xml
file:
sudo kiwix-manage /home/admin/kiwix-library/library.xml add /home/admin/kiwix-library/medlineplus.gov_en_all_2025-01.zim -u https://download.kiwix.org/zim/zimit/medlineplus.gov_en_all_2025-01.zim
Start the Kiwix server on port 80 using your library file:
sudo kiwix-serve --port=80 --library /home/admin/kiwix-library/library.xml
You can now access the Kiwix server by navigating to your Raspberry Pi's IP address in a web browser.
To start Kiwix on port 80 after boot up:
sudo nano /etc/systemd/system/kiwix.service
Add the following:
[Unit]
Description=Kiwix Serve
After=network.target
[Service]
ExecStart=sudo /usr/bin/kiwix-serve --port=80 --library /home/admin/kiwix-library/library.xml
WorkingDirectory=/home/admin/kiwix-library
User=admin
Group=admin
Environment=DISPLAY=:0
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
Finally, run the following:
sudo systemctl daemon-reload
sudo systemctl enable kiwix.service
sudo systemctl start kiwix.service
sudo systemctl status kiwix.service
- Permission Issues: Ensure you run commands with
sudo
if required. - Port Conflicts: If port 80 is used, choose another port with the
--port
flag. - File Download Problems: Verify your internet connection and the URL of the ZIM file.
Enjoy using Kiwix on your Raspberry Pi for offline browsing!