Methods of payment Abuse

How to Host Wikipedia and Arch Wiki on Raspberry Pi Using Kiwix

04.12.2024, 17:22

Whether you're preparing for the end of the world or simply want all your information at hand even when the internet is unreliable, Kiwix helps you quickly and easily save a copy of the Wiki project you're interested in offline.

What is Kiwix?

Kiwix is a platform that creates compressed versions of websites in the form of individual .zim files. These files are small enough to be stored even on a smartphone, computer, or server.

What you need to work with Kiwix

  • Raspberry Pi (not necessarily the latest model).
  • Storage — about 90 GB of free space. You can use memory cards at first, but later we recommend connecting an SSD to your "Pi" for better speed and reliability.
  • Internet connection.

Installing Kiwix in a Docker Container

Step 1: Download the ZIM file for Kiwix

Go to the Kiwix library, find the version of Wikipedia or any other file that meets your needs, and download it before proceeding to the next step.
Click on "Download - 38.29MB," and a window with download options will pop up.

Step 2: Running the Docker Container

Method 1: Docker Run
This command allows you to run the Kiwix container without any issues:

docker run -v /home/user/kiwix:/data -p 8080:8080 ghcr.io/kiwix/kiwix-serve '*.zim'

Now, let's break down this command:

  • docker run: The basic command to start a new Docker container.
  • -v /home/user/kiwix:/dаta: This option maps a folder on the host machine (/home/user/kiwix) to a folder inside the container (/data).
  • -p 8080:8080: This maps port 8080 inside the container, so you can access the Kiwix service by going to http://localhost:8080 in your web browser.
  • kiwix/kiwix-serve: Specifies the Docker image to use.
  • *.zim: This part tells the Kiwix server to serve all files with the .zim extension from the /data folder.

Method 2: Docker Compose
An alternative option is to use docker-compose.
Create a YAML file named docker-compose.yml and add the following dаta:

version: '3'
services:
  kiwix-serve:
    image: ghcr.io/kiwix/kiwix-serve
    volumes:
      - /home/user/kiwix:/data
    ports:
      - '8080:8080'
    command: '*.zim'

Let's break down the docker-compose.yml file:

  • version: '3': Specifies the version of Docker Compose.
  • services:: Specifies the services to run, in this case, the Kiwix server.
  • image: ghcr.io/kiwix/kiwix-serve:3.7.0: Uses the Kiwix server Docker image.
  • volumes:: Maps the host folder (/home/user/kiwix) to the container's /data folder, providing access to the ZIM files.
  • ports:: Maps port 80 inside the container to port 8080 on the host for web access.
  • command:: Tells the Kiwix server to serve all ZIM files with the .zim extension from the /data folder.

Next, run the command:

docker-compose up -d

This will start the Kiwix server in daemon mode on port 8080.

After that, you can use your local Wikipedia. You just need to go to your local IP address in your browser.
If you want a reliable offline knowledge base, Kiwix is a great place to start, especially when you only have an inexpensive single-board computer and half an hour of free time.