Jump to content

FreedomBox for Communities/Offline Wikipedia

From Wikibooks, open books for an open world

Offline availability of Wikipedia pages, Project Gutenberg, Stack Exchange and other content can be useful for education, especially in situations where Internet connectivity is intermittent or when the bandwidth is congested or metered. It could also be suitable for a class room that might otherwise not have Internet access.

Kiwix is an application that can serve a web interface on which users can browse pages and search them.

Installing Kiwix

[edit | edit source]

Install Kiwix on the FreedomBox server machine by following these instructions.

  1. Download and install kiwix-tools from Kiwix website. Do this as the root user.
    sudo su -
    cd
    wget https://download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-x86_64.tar.gz
    tar -xf kiwix-tools_linux-x86_64.tar.gz
    cp kiwix-tools*/* /usr/local/bin
    

    Explanation: Kiwix used to be available in Debian package repositories, but isn't anymore.[1] The workaround is to install via tarball, as described above. However, the tarball method may make it hard to update or uninstall Kiwix, should this become necessary. Alternatively, it may be possible to use a flatpack, but this is untested. The potential benefits would be the usual ones gained from using a Package manager.

  2. Create a folder for holding Kiwix library in the /srv folder (this can be separate disk so that it can hold larger volumes of data).
    mkdir -p /srv/apps/kiwix
    
  3. Download files from Kiwix content download page.
    cd /srv/apps/kiwix
    wget http://download.kiwix.org/zim/wikipedia_en_simple_all_nopic.zim
    
  4. Create and add the .zim files to a library file. Add as many .zim file as you wish in a similar way.
    kiwix-manage /srv/apps/kiwix/library.xml add /srv/apps/kiwix/wikipedia_en_simple_all_nopic.zim
    
  5. Setup kiwix web service to run on the system as soon as the system starts.
    addgroup --system kiwix
    adduser --system --ingroup kiwix --home /srv/apps/kiwix --gecos 'Kiwix - Offline Wikipedia' kiwix
    cat << EOF > /etc/systemd/system/kiwix.service
    [Unit]
    Description=Kiwix - Offline Wikipedia After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/kiwix-serve --library --port=4201 --urlRootLocation=/kiwix /srv/apps/kiwix/library.xml
    User=kiwix
    Group=kiwix
    
    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl daemon-reload
    systemctl enable kiwix
    systemctl start kiwix
    
  6. Create Apache configuration to forward requests on /kiwix to kiwix.
    cat << EOF > /etc/apache2/conf-available/kiwix.conf
    <Location /kiwix>
        ProxyPass http://localhost:4201
    </Location>
    EOF
    a2enconf kiwix
    systemctl reload apache2
    

Adding new content repositories

[edit | edit source]
  1. Login as root user and download files from Kiwix content download page.
    sudo su -
    cd /srv/apps/kiwix
    wget <url_to_zim_file>
    
  2. Add the .zim files to a library file.
    kiwix-manage /srv/apps/kiwix/library.xml add </path/to/zim/file.zim>
    

Accessing Kiwix

[edit | edit source]

Visit the URL http://<myfreedombox.domain>/kiwix/ . You should see an interface showing a entry for each of the .zim file added. Select the entry to start browsing the content of the .zim file. There is also a search interface available to allow you to search within all of the offline content available.

  1. https://wiki.kiwix.org/wiki/Debian