Hosting a Gemini ServerApr 17, 2021
Similar Article Available
To read more about Gemini and ways to test out this new protocol without your own server, see my previous post Launching a Gemini Capsule.
This guide assumes you have access to a server accessible to the world through a public IP address and that you own a domain name used for this Gemini capsule.
Getting Started with Agate
We are going to use Agate for this tutorial. This is a very simple Gemini server written in Rust. It takes very little time and maintenance to get it running.
First, you will need to install the Rust package for your system. On Ubuntu, use the following commands (remember to use sudo if you are not the root user). The Rust installation will give you options to customize the installation - I used the default installation options.
apt update && apt upgrade -y curl https://sh.rustup.rs -sSf | sh
Remember to configure your shell with the new configuration:
Next, you’ll need to install the agate executable with Rust’s Cargo package maintainer:
cargo install agate
Once Cargo has finished installing all of the required packages, symlink the executable to your $PATH.
ln -s $HOME/.cargo/bin/agate /usr/local/bin/agate
Using Agate’s Built-In Installation Tool
Since we’re running Ubuntu, we’re going to use the Debian install script found in Agate’s GitHub repository, under the tools/debian folder.
git clone https://github.com/mbrubeck/agate cd agate/tools/debian ./install.sh
Configure the Gemini Service
We have a little more to do, but since this script tries to immediately run the service, it will likely fail with an exit code. Let’s add our finishing touches. Edit the following file and replace the hostname with your desired URL. You can also change the directory where content will be served.
# Edit these lines to whatever you want - see the next code block for my personal configuration. WorkingDirectory=/srv/gemini ExecStart=agate --hostname $(uname -n) --lang en
This is my personal config:
WorkingDirectory=/var/gmi ExecStart=agate --hostname gemlog.cleberg.io --lang en
Since we’ve altered the systemd configuration files, we have to reload the daemon. Let’s do that, restart our service, and check its status.
systemctl daemon-reload systemctl restart gemini.service systemctl status gemini.service
Fixing Systemd Errors
If you’re still getting errors, the installation process may not have properly enabled the gemini service. Fix it with the following commands.
systemctl enable gemini.service systemctl restart gemini.service systemctl status gemini.service
Great! Our server is now functional and running. The first consideration now is that you need to be able to access port 1965 on the server. If you have a firewall enabled, you’ll need to open that port up.
ufw allow 1965 ufw reload
Let’s create the Gemini capsule. Note that wherever you set the WorkingDirectory variable to earlier, Agate will expect you to put your Gemini capusule contents in a subfolder called “content”. So, I place my files in “/var/gmi/content”. I’m going to create that folder now and put a file in there.
mkdir /var/gmi/content nano /var/gmi/content/index.gmi
You can put whatever you want in the “index.gmi” file, just make sure it’s valid Gemtext.