summaryrefslogtreecommitdiff
path: root/gemini.html
blob: 4963f2ab8c7c0acd68f05f87cef011fda5e80f75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang=en>
    <head>
        <title>How to set up your own gemini server</title>
        <meta charset="utf-8"/>
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
        <link rel='stylesheet' type='text/css' href='style.css'>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'>
    </head>
<body>
    <header><h1> Creating and serving gemini capsules </h1></header>
    <nav></nav>
    <main>
        <h2 id="whatis">What is Gemini?</h2>
        <p><a href="https://gemini.circumlunar.space" target="_blank">Gemini</a> is a  new internet protocol which is different from the HTTP and Gopher. It's much cleaner and has a growing community and audience of hackers.</p>
        <h3>Why use gemini protocol?</h3>
        <ul>
            <li>Gemini capsules (webpages of gemini) are lightweight, minimal, and don't use many resources to operate.</li>
            <li>It can run along with your websites. Gemini capsules use port 1965 by default. Your webserver can run at port 80 or 443 along with gemini server at port 1965. </li>
            <li>By exploring an alternative protocol, you can check different ways to serve data and blogs.</li>
        </ul>
        <p>To access any gemini urls i.e. <code>gemini://example.org</code>, you can use any gemini client such as <a href="https://github.com/makeworld-the-better-one/amfora" target="_blank">amfora</a>, <a href="https://gmi.skyjake.fi/lagrange" target="_blank">lagrange</a>, <a href="https://thelambdalab.xyz/elpher/" target="_blank">elpher</a>, etc.
        <h2 id="instructions">Instructions</h2>
        <h3>Create a gemini user</h3>
        <p>
        It is most secure and clean to have a separate <code>gemini</code> user, so let's create one:
        </p>
        <pre><code>useradd -m -s /bin/bash gemini</code></pre>
        <p>Now log in as <code>gemini</code> with the following command:</p>
        <pre><code>su -l gemini</code></pre>
        <p>To create and serve a gemini capsule, we need three basic steps:</p>
        <ol>
                <li>Content &ndash; the webpages in our capsule</li>
                <li>TLS certificate &ndash; Gemini requires encrypted connection.</li>
                <li>Gemini server &ndash; the program that makes our capsule available (similar to Nginx for HTTP)</li>
        </ol>
        <p>As the gemini user, we can create three different directories to simplify the process:</p>
        <pre><code>mkdir -p ~/gemini/{content,certificate,server}</code></pre>
        <h3>Content</h3>
        <p>This will be the directory where you capsule files will be contained. Gemini uses text/gemini markup (in place of HTTP's equivalent HTML). It heavily borrows from Markdown. Similar to .html or .md, gemini uses .gmi as its extension.</p>
        <p>To create one gemini file, go inside the <code>content</code> directory and create one <code>index.gmi</code> file.</p>
        <pre><code>nano gemini/content/index.gmi</code></pre>
        <p>We can add the content we want in our Gemini capsule here:</p>
        <pre><code># This is Sample Gemini page
## With header 1 and header 2
And a short paragraph like this.
=> /index.gmi Link to the same page</code></pre>
        <h3>TLS certificate</h3>
        <p>Go to the <code>certificate</code> directory which we created earlier and generate a TLS certificate using OpenSSL.</p>
        <pre><code>cd ~/gemini/certificate/
openssl req -new -subj "/CN=<strong>example.org</strong>" -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -days 3650 -nodes -out cert.pem -keyout key.pem</code></pre>
        <h3>Gemini server</h3>
        <h4>Download and prepare the server</h4>
        <p>There are <a href="https://gemini.circumlunar.space/software">many gemini server software choices available</a>.
        We will use <code>agate</code> server for now. This is a simple gemini server written in Rust.</p>
        <p>It's a good idea to always get the most recent version, which you can see <a href="https://github.com/mbrubeck/agate/releases">on the agate releases page</a>. At the time of this writing, that is agate v3.1.0 which we will now download. We will download it to the <code>server</code> directory we made.</p>
        <pre><code>cd ~/gemini/server
wget https://github.com/mbrubeck/agate/releases/download/v3.1.0/agate.x86_64-unknown-linux-gnu.gz</code></pre>
        <p>Unzip the gz, then rename and make it executable:</p>
        <pre><code>gunzip agate.x86_64-unknown-linux-gnu.gz
mv agate.x86_64-unknown-linux-gnu agate-server
chmod +x agate-server</code></pre>
        <h4>Create a system service</h4>
        <p>Now we need to create a systemd service to autostart and manage agate.
        The gemini user does not have permission to do this, so press <code>ctrl-d</code> to log out of the gemini user and return to root.
        As root, create the file below by opening it in your text editor (nano, vim, etc.):</p>
        <pre><code>nano /etc/systemd/system/agate.service</code></pre>
        <p>Add the following content to the file <strong>customizing highlighted text</strong> to your use.</p>
        <pre><code>[Unit]
Description=agate
After=network.target

[Service]
User=gemini
Type=simple
ExecStart=/home/gemini/gemini/server/agate-server --content /home/gemini/gemini/content --certs /home/gemini/gemini/certificate/ --hostname <strong>example.org</strong> --lang <strong>en-US</strong>

[Install]
WantedBy=default.target</code></pre>
        <p>Now we are ready to run server. Enable and run agate server.</p>
        <pre><code>systemctl enable agate
systemctl start agate</code></pre>
        <h4>Firewall</h4>
        <p>Lastly, if you have a firewall running, remember to open port 1965, which is the port number used by gemini:</p>
        <pre><code>ufw allow 1965</code></pre>
        <h2>Finalization</h2>
        <p>Now your server should be running. If everything went okay, you can access your gemini capsule via any gemini client with a url like this:</p>
        <pre><code>gemini://<strong>example.org</strong></code></pre>
        <p>Sample gemini site for reference:</p>
        <pre><code>gemini://gemini.circumlunar.space</code></pre>
        <p>Enjoy your first gemini capsule.</p>
        <p>
        For information about how to write in "gemtext" the markup language in Gemini, see this site: <a href="https://gemini.circumlunar.space/docs/gemtext.gmi">https://gemini.circumlunar.space/docs/gemtext.gmi</a>.
        As you might guess it also has an analogous gemini capsule here: gemini://gemini.circumlunar.space/docs/gemtext.gmi
        </p>
        <hr>
        <p><em>Written by <a href="https://nihar.page">nihar.page</a></em></p>

    </main>
	<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer>
</body>
</html>