As part of the KGL Mainframe project I wanted a local copy of Wikipedia and Kiwix made this simple (compared to my previous attempts). Last night I had the idea to use this as my default search engine, for a number of reasons:


* It produces very high-quality results
* It is super fast
* It enhances privacy
That last one is a pretty big deal. By performing the majority of my web searches this way, what I'm searching for never leaves the LAN. I don't need to elaborate on why that makes things a lot safer and less annoying. It's true that Wikipedia doesn't have everything someone might be searching for, and that the copy I'm running locally isn't as up-to-date as the version of Wikipedia on the Internet, but I've been testing this for a bit (and I've used regular Wikipedia as a search engine in the past) and it turns out that it's good for about 90% of what I'm usually looking for. When it's not, I can always use something else and take extra precautions if necissary.
Fortunately this is pretty easy to setup, the hardest part was figuring out how to convince the desktop version of Firefox to allow me to do so (remember when Firefox respected it's users? I miss that).
The easiest way to do this is probably to download run kiwix-serve (it's a single binary you can download here) locally. With that and a ZIM file (the full Wikipedia file is about 100GB) you'll have everything you need and you'll just need to configure your browser to use it as a search engine.
I set this up on the mainframe as a service which is a little more involved so I'll come back to that later.
Once you have kiwix-serve running you need to add a new search engine to your browser that uses a URL like this:
You may need to change the value wikipedia_en_all_maxi_2024-01 to something else if you downloaded a different ZIM file.
As I alluded to above, Firefox now makes this hard. The first step is to beg permission to add a new search engine, which requires using a secret setting. Open a new tab and type about:config and press enter. In the "Search preference name" field type browser.urlbar.update2.engineAliasRefresh. On the right click the "toggle" button (it looks like two arrows pointing left and right). Now you should be able to go to the regular Settings page and add a new search engine.

Why is this disabled in the first place? I assume it's to protect Google's profits or some such nonsense.
Be sure to give it a name so you know what to select when you switch the default search engine, but the Alias is optional.
Now whenever you type something in the search bar the results will come directly from your own machine, no ads, no surveillance and super fucking fast.
If you want others on your network to have access to this (or you don't want to/can't run it locally) setting-up a server doesn't take much more work. On a Linux server, setup and run it just like you would locally, and try accessing the server the same, but include the server's name in the URL instead of localhost:
If that works, you can make the setup more permanent using the following steps:
1. Copy kiwix-serve to /usr/bin
2. Copy the ZIM file somewhere stable (i.e. not some random home directory)
3. Create a new file named kiwix.service in /etc/systemd/system/ with the following contents
[Unit]
Description=kiwix-serve
[Service]
Restart=always
RestartSec=15
User=somevaliduser
ExecStart=/usr/bin/kiwix-serve -p 8885 /data/wikipedia.ZIM
[Install]
WantedBy=network-online.target
You will need to set the User to a valid user for your system and the port & path after kiwix-server to correct values for your system.
After that you should be able to enable & start the server like this:
sudo systemctl enable kiwix.service
sudo systemctl start kiwix.service
Then check the status with
sudo systemctl status kiwix.service
If all is well your browser should once again search against the server, and you can point other clients at it as well.
So far this has worked very slick for me. I've tested it with both desktop and mobile (iOS) versions of Firefox. The same sort of thing should work for other browsers, but the steps to set them up will be different.
I'd like to expand this to search other collections I'm hosting using Kiwix but I'll have to do a little more experimentation to find the best way to do that.