HOWTO Setup GmCapsule

Overview

Background

I like GmCapsule as a gemini server because it's easy to install, is written in Python, supports CGI, and has support for the Titan protocol. I've been using it for a while now and @skyjake actively maintains it.

Step 1: Install GmCapsule

Step 2: Create Server Cert/Key

Step 2a: Download and Build GemCert:

Note: Just "go build" wasn't working for me but 'go build main.go' did, so I just renamed the file to gemcert after it built

Step 2b: Generate Cert/Key:

Explanation:

Step 2c: Move the Keys to Your Cert Directory

Explanation:

Step 3: Create Your Folder Structure

GmCapsule requires your content to be served out of a folder that is the same name as your domain / host, e.g., "gemini.smallweb.space/"

Example folder structure:

Notice how both directories have a subdirectory of "localhost" since that's my "domain" for my local computer. Of course, you'd rename to your actual domain specified in your .gmcapsulerc

Step 3a: Create index.gmi

And drop in:

Step 4: Configure the Server

The default user location for .gmcapsulerc is ~/.gmcapsulerc. Since it doesn't exist, we'll make it.

A full example file can be found on the GmCapsule User Manual:

GmCapsule User Manual

Let's put in some real basic defaults to get our server going

Explanation:

Step 5: Test It Out

Manually fire up the server and see what happens

Step 5a: Open Port 1965 (if necessary)

If you're using ufw or something similar, open port 1965

Step 5b: Test it out

Fire up your Gemini client and navigate to your site. If you're doing local hosting, this would be: gemini://localhost/index.gmi

And you should see your index.gmi page from above:

Hello World!
Test Page

Step 6: Troubleshooting

I had an SSL issue when starting GmCapsule:

AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'

Which led me to this page:

StackOverFlow

Short answer, upgrade pyopenssl:

Certificate Errors

If you get certificate errors, make sure:

Step 7: Daemonize GmCapsule

If you run the server manaully, it'll stop once you log out or end it. To get around this you would daemonize your program in order to start every time the server starts. Most systems use Systemd, so that will be detailed here.

and put something like this in there (modify to your install)

Then enable and start it:

Since our service ('SysLogIdentifier') is called 'gmcapsule' we can check its status with journalctl:

The End

And that's pretty much it. Now the hard part is making content.

The finer details of configuring GmCapsule are in the User Manual:

GmCapsule User Manual

Check out my other HOWTO that gives example CGI scripts, and describes what else you can do with your own capsule:

Managing a Capsule on a Server You Own

2024-02-22

Gritty