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
|
<!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.</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://landchad.net</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>
<p>To create and serve a gemini capsule, we need three basic steps:</p>
<ol>
<li>Content</li>
<li>TLS certificate</li>
<li>Gemini server</li>
</ol>
<p>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>Gemini uses text/gemini markup. 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>touch gemini/content/index.gmi</code></pre>
<p>Update the file content of index.gmi</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 have created earlier. Generate the TLS certificate using OpenSSL. Change YOURDOMAIN.COM to the domain of your gemini capsule.</p>
<pre><code>openssl req -new -subj "/CN=YOURDOMAIN.COM" -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -days 3650 -nodes -out cert.pem -keyout key.pem</code></pre>
<h3>Gemini server</h3>
<p>There are many gemini servers available. You can check the list of servers <a href="https://gemini.circumlunar.space/software" target="_blank">here</a>.</p>
<p>We will use <code>agate</code> server for now. This is a simple gemini server written in Rust. Go to <code>server</code> directory and download agate server.</p>
<pre><code>wget https://github.com/mbrubeck/agate/releases/download/v3.1.0/agate.x86_64-unknown-linux-gnu.gz</code></pre>
<p>Unzip the gz</p>
<pre><code>gunzip agate.x86_64-unknown-linux-gnu.gz</code></pre>
<p>Rename and make it executable</p>
<pre><code>mv agate.x86_64-unknown-linux-gnu agate-server
chmod +x agate-server</code></pre>
<p>Now we need to create a systemd service</p>
<pre><code>sudo touch /etc/systemd/system/agate.service</code></pre>
<p>Copy the below file and paste in agate.service.</p>
<pre><code>[Unit]
Description=agate
After=network.target
[Service]
User=USER
Type=simple
ExecStart=/home/USER/gemini/agate-server --content /home/USER/gemini/content --certs /home/USER/gemini/certificate/ --hostname YOURDOMAIN.COM --lang en-US
[Install]
WantedBy=default.target</code></pre>
<ul>
<li>Change <code>/home/USER/gemini</code> to your gemini directory path.</li>
<li>Change <code>YOURDOMAIN.COM</code> to your domain without http/https.</li>
<li>Change <code>en-US</code> to your country language. en-IN for India, en-GB for UK, etc.</li>
</ul>
<p>Now we are ready to run server. Enable and run agate server.</p>
<pre><code>systemctl enable agate
systemctl start agate</code></pre>
<h2>Finalization</h2>
<p>Now your server should be running. If everything went okay, you can access your gemini via any gemini client with this url</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>
<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><li><a href="index.html"><img src="pix/chad.gif" alt="chad"></a></li><li><a href="rss.xml"><img src="pix/rss.svg" alt="RSS"></a></li><li><a href="pix/btc.png"><img src="pix/btc.svg" alt="BTC"></a></li><li><a href="pix/xmr.png"><img src="pix/xmr.svg" alt="XMR"></a></li><li><a href="https://github.com/lukesmithxyz/landchad"><img src="pix/git.svg" alt="Github"></a></footer>
</body>
</html>
|