# Setting up Molly-Brown on Ubuntu

Originally posted on 2023-04-11

[ Ubuntu version: 22.04 ]

## Install it

This will NOT fully install the service; it just gets the code ready in the right place.

```
apt install molly-brown
```

## Create the Molly-Brown unit file (service file) for SystemD

```
nano /etc/systemd/system/molly-brown.service
```

The basic setup looks like this. Note that this is running as root. I'd like to change this at some point, but I don't know how (yet).

```
[Unit]
Description=Molly Brown gemini server
After=network.target multi-user.target

[Service]
Type=simple
Restart=always
#User=molly
ExecStart=/usr/bin/molly-brown -c /etc/molly.conf

[Install]
WantedBy=multi-user.target
```

## Create the CONF file

```
/etc/molly.conf
```

The basic CONF file looks like this:

```
## Basic settings
#
Port = 1965
Hostname = "tiny.local"
CertPath = "/etc/ssl/certs/selfsigned.crt"
KeyPath = "/etc/ssl/private/selfsigned.key"
DocBase = "/var/gemini/"
HomeDocBase = "users"
GeminiExt = "gmi"
DefaultLang = "en"
AccessLog = "/var/log/molly/access.log"
ErrorLog = "/var/log/molly/error.log"
ReadMollyFiles = true

## Directory listing
#
DirectorySort = "Time"
DirectorySubdirsFirst = false
DirectoryReverse = true
DirectoryTitles = true

## Dynamic content
#
#CGIPaths = [
#       "/var/gemini/cgi-bin",
#       "/var/gemini/users/*/cgi-bin/", # Unsafe!
#]
#
#[SCGIPaths]
#"/scgi-app-1/" = "/var/run/scgi1.sock"
#"/scgi-app-2/" = "/var/run/scgi2.sock"

## MIME type overrides
#
[MimeOverrides]
"atom.xml$" = "application/atom+xml"
"rss.xml$" = "application/rss+xml"

## Redirects
#
#[TempRedirects]
#"/old/path/file.ext" = "/new/path/file.ext"
#[PermRedirects]
#"/old/path/file.ext" = "/new/path/file.ext"

## Certificate zones
#
#[CertificateZones]
#"^/secure-zone-1/" = [
#       "d146953386694266175d10be3617427dfbeb751d1805d36b3c7aedd9de02d9af",
#]
#"^/secure-zone-2/" = [
#       "d146953386694266175d10be3617427dfbeb751d1805d36b3c7aedd9de02d9af",
#       "786257797c871bf617e0b60acf7a7dfaf195289d8b08d1df5ed0e316092f0c8d",
#]
```

## Create needed files and folders

```
# Logs
touch /var/log/molly/access.log
touch /var/log/molly/error.log

# SSL Certificate
# (Replace with 3rd party cert later)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/selfsigned.key -out /etc/ssl/certs/selfsigned.crt

# Create the default path and default .gmi page
mkdir /var/gemini
nano /var/gemini/index.gmi

# Put whatever you want in the index.gmi file...
```

5. Start the service and test

```
service molly-brown start
```

If it all works, you're good. If not, ummm, sorry?

6. Enable the service

```
systemctl enable molly-brown.service
```

Done.

## Some other things you might want to do

### User directories

Molly-Brown supports ~/user style user dirctories, but I'm not sure how to use those at the moment. One way I've found around this is to create softlinks to user's "public_gemini" folders u>

```
# "public_gemini" isn't really needed - it could be any folder. I just like to have all my Gemini, Gopher, and WWW folders in a row
ln -s /home/<username>/public_gemini <username>
```

Similar to a user directory in Gophernicus (~/public_gopher), the user will need to create a "public_gemini" folder. This folder should be world readable (as far as I can tell).