Skip to main content

Installing Ditto

This guide will explain how to install Ditto on a Linux VPS using deno, systemd, and nginx. You'll additionally need to have curl and git installed.

sudo apt install curl git # Ubuntu/Debian
sudo rpm install curl git # Fedora/RHEL
sudo pacman -S curl git # Arch Linux

Install Deno

To install Deno system-wide, run:

curl -fsSL https://deno.land/x/install/install.sh | sudo DENO_INSTALL=/usr/local sh

To upgrade this installation at a later date, run:

sudo deno upgrade

Create a Linux user for Ditto

Create a new user to run the Ditto service:

sudo adduser ditto

Clone source code

mkdir /opt/ditto
cd /opt/ditto
chown -R ditto:ditto .
su ditto

git clone https://gitlab.com/soapbox-pub/ditto.git /opt/ditto
exit

Set up a frontend

Ditto can operate on its own as a Nostr relay, but to unlock its full potential, we recommend you use it with a frontend. Soapbox is a React-based UI for decentralized social media focused on custom branding and ease of use.

You can download it from https://dl.soapbox.pub/. Once it is done, unzip it into /opt/ditto/public/.

Add systemd unit

Create a new systemd unit file at /etc/systemd/system/ditto.service:

[Unit]
Description=Ditto
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=ditto
WorkingDirectory=/opt/ditto
ExecStart=/usr/local/bin/deno task start

# Environment variables for configuring Ditto

# The private key Ditto uses to sign events.
Environment="DITTO_NSEC=nsec1..."

# change this to the domain you are hosting Ditto on.
Environment="LOCAL_DOMAIN=http://localhost:4036"

# change the following line to change the local port Ditto listens on.
# Environment="PORT=4036"

Restart=on-failure

[Install]
WantedBy=multi-user.target

Modify the Environment="DITTO_NSEC=nsec1..." line to include a new nsec generated by running deno run /opt/ditto/scripts/nsec.ts.

Then run systemctl daemon-reload followed by systemctl enable --now ditto.

Configure your reverse proxy

Typically, you should be running Ditto behind a reverse proxy. You will need to proxy the external port 443/80 of your server to the port Ditto listens on, along with serving the static files required for Ditto to function. Detailed instructions for setting up reverse proxies can be found here.