Build a Gemini Server on Linux and Join the Web That Might Have Been
Gopher is an internet protocol that existed in the early 1990s but ultimately lost out to HTML and the World Wide Web. It still exists today and Gemini is its spiritual successor, with improved security, and thousands of independent servers (known as capsules) running on low-cost hardware.
The numbers are insignificant when compared with the web we know and love, but with a small amount of effort, you can swell the capsule ranks by one. Read on to find out how to set up your own Gemini server.
How Gemini Is Different From Gopher
Gopher failed because its technology was proprietary—unlike the tech behind the World Wide Web. Gemini does not make the same mistake, and the server software is free and open source, so anyone can use, adapt, and distribute it as they please.
In common with many retro-computing projects, both Gopher and Gemini use puns excessively. Gopher was so called because if users requested a resource, it would “go for” them. Gopher sites were called Gopher Holes.
Gemini is themed around space exploration, and the name refers to the Gemini space program. Gemini sites are called capsules, and the port used is 1965—commemorating the first crewed Gemini spaceflight in 1965.
Gemini also has a greater emphasis on security than Gopher—requiring self-signed certificates for every capsule.
Setting Up a Gemini Capsule Is Cheap
Practically any computer produced in the past 30 years can host a Gemini capsule—provided it’s capable of running a Linux distro. Raspberry Pis are especially popular due to their low cost and low energy consumption. Because the resources used by Gemini are so minuscule, a high-end Pi such as the Raspberry Pi 4B is overkill and is better employed in more demanding projects. A Raspberry Pi Zero W will perform perfectly well.
You will also need a domain name or a spare subdomain. If you do not already have one, read our guide on how to choose and buy a domain name.
Hosting a Gemini Capsule on Your Pi Zero Is Simple
First, visit your domain name registrar and create a new DNS record for your domain name. Set the type as A, the host as @, and the value as the public IP address of your home. We’ve explained how to find your public IP address from a Linux system if you need help. Set the TTL value as low as possible.
Now go to the admin page for your router. You can access this by pointing a browser to 192.168.1.1. If this does not work for you, consult your router manual.
Look for a section named Port Forwarding, Port Mapping, or Port Management, and create a new entry for Gemini. The local IP address should be the local IP address of your Pi, the protocol is TCP, and both the local and public ports should be 1965.
If you have already installed a distro on your Raspberry Pi, you should SSH into the machine:
…where user is your username and xxx.xxx.x.xx is the local IP address of your Raspberry Pi.
Update and upgrade the repository list and packages on the system by typing:
sudo apt update
sudo apt upgrade
Now create a new directory for Gemini:
The gemini directory will hold the contents of your Gemini capsule—the most important part of which is index.gmi. Go ahead and make one with:
Gemini uses Markdown language. If you’re not yet comfortable with this, read our beginner’s guide to getting started with Markdown.
The index page should contain an introduction to your Gemini capsule and other useful information.
Save and exit the file with Ctrl + O then Ctrl + X.
Create a new directory called bin within the gemini directory and cd into it:
In your browser, visit Agate on GitHub and under the “Assets” section, identify the correct package for your hardware. A 64-bit Raspberry Pi 4B would require agate.aarch64-unknown-linux-gnu.gz, while a 32-bit Pi Zero W, would require agate.armv7-unknown-linux-gnueabihf.gz.
Right-click on the appropriate package name to get the link address then paste it after the wget command to download the package to your current directory.
Extract the package with:
Remember that the package name will be slightly different depending on which architecture it was downloaded for. Rename the extracted file:
mv agate.aarch64-unknown-linux-gnu.gz agate
Make it executable with:
sudo chmod +x agate
cd back to your home directory and create a shell script using nano:
Into the file, paste the following, making sure that you change “example.com” to your actual domain name:
Save and close with Ctrl + X then Ctrl + O and make the script executable:
sudo chmod +x gemini.sh
Start your Gemini capsule with:
Access Your Gemini Capsule From Anywhere
Gemini is not the web, and you can’t use a normal web browser to access it. There are, however, a number of browsers that can visit both Gopher holes and Gemini capsules. We recommend Kristall, which is available for Windows, macOS, and Linux. Download and install on your regular machine.
You can access your Gemini capsule by typing gemini://example.com into the address bar, where example.com is your domain name!
Expand Your Gemini Capsule With More Pages
You can now create and run a Gemini capsule on your Raspberry Pi. One page is enough for a very simple information site, and you can create more by adding .gmi files to your content folder. Think about what interests you and what content visitors would want to read. Similarly, you can also create and access Gopher holes on Linux.