This guide was created in part from the article written by Mr.
Rick Makes.
My Raspberry Pi 4 was installed with Raspbian Buster.
Update your Raspberry Pi
sudo apt-get update
&& sudo apt-get upgrade -y
Download the latest version of Kiwix Server from
https://www.kiwix.org/en/downloads/kiwix-serve/
cd
/home/pi/Downloads
Decompress the downloaded file
tar -zxvf
kiwix-tools_linux-armhf.tar.gz
Install the Kiwix binaries
sudo mv
kiwix-tools_linux-armhf-3.*.*/* /usr/local/bin/
Do take note the version number
when moving the binaries over
Downloading the wiki archives, which are in zim
format. Go to https://wiki.kiwix.org/wiki/Content_in_all_languages
as you scroll down, look for the wiki in the language of your choice. For this example, I choose the total
Wikipedia which is about 79Gb in size.
It would be better to choose only those sections you want, as they are
more updated and smaller in size.
Copy the download link address and
download the file
After all the wiki files are downloaded, move
them to the /var/local/ directory
sudo mv *.zim /var/local/
Create the Kiwix Service
sudo nano
/etc/systemd/system/kiwix.service
It should open nano editor with
a blank file.
Paste the following into the
editor:
[Unit]
Description=Kiwix
Service
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/kiwix-serve
–library /var/local/library_zim.xml -p 80
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
CTRL-O to
save the file
CTRL-X to
exit the editor
The above will run will run on port 80 ( -p 80 ), you can
specify other ports, but make sure when you access from your web browser, you
need to append the port number at the end of the address, for example, http://raspberryIPaddress:8181 port is set to 8181 ( -p 8181 )
Add the downloaded wiki zim formatted files into
the library. For example you download 3
files, let’s call them wiki_history.zim, marine_conservation.zim, and
abstract_arts.zim.
You would need to do the
following command to add those 3 zim files
sudo kiwix-manage
/var/local/library_zim.xml add /var/local/wiki_history.zim
sudo kiwix-manage
/var/local/library_zim.xml add /var/local/marine_conservation.zim
sudo kiwix-manage /var/local/library_zim.xml
add /var/local/abstract_arts.zim
sudo
kiwix-manage /PATH/xmlfile add /var/local/zimfile
Those three files will be
indexed into library_zim.xml.
To learn more about kiwix-manage go to https://wiki.kiwix.org/wiki/Kiwix-manage
Enable Kiwix Service (automatically run when
Raspberry Pi boots up)
sudo
systemctl enable kiwix.service
To understand more of the
command, you go to https://fedoramagazine.org/what-is-an-init-system/
or you can type the following in the command prompt
man systemctl
To start the Kiwix Service
sudo systemctl start
kiwix.service
To stop the Kiwix Service to add more wiki zim files, see #8 above
sudo
systemctl stop kiwix.service
After you had finished adding
the new wiki zim files, restart Kiwix Service
sudo systemctl start
kiwix.service
Optional
If the Raspberry Pi is used in a kiosk environment or in a public
sharing place, to prevent accidental changes to settings or deletion of files,
you need to write protect filesystems and boot partition.
To Enable Read Only System
sudo
raspi-config
Go to Advanced Options
Select Overlay FS
Choose Yes to enable overlay file system
Choose Yes to write protect boot partition
Reboot, and you are done. I hope
you find this guide useful. Stay safe. God Bless.
Useful Resources:
Thinking of running Kiwix-serve on a Docker container. There is an image on DockerHub.
ReplyDeleteI am trying out Graham's IOTstack to learn about Dockers.
https://github.com/gcgarner/IOTstack/wiki
Went step by step according to the instructions above and can't get anything to connect via http to the server...
ReplyDeleteThis line in your code has been mangled by your CMS or text editor. There are supposed to be TWO hyphens in front of "library". IE "--library". Not one. Anyone copy-pasting that will have errors.
ReplyDeleteExecStart=/usr/local/bin/kiwix-serve --library /var/local/library_zim.xml -p 80