Akkoma | All Posts | Links | About

# The Teabag Ninja

No really, I don't sell teabags!

### Installing Akkoma

November 26, 2022

Before starting, have a read over https://docs.akkoma.dev/stable/installation/otp_en/ to familiarise yourself with the process. This guide is mostly a copy of that, with some adjustments for clarity. Hopefully.

OTP releases are the closest that Elixer has to a binary release.

# Prepare your system

This guide assumes a Debian 11 install on Linode, but should work the same for any install of Debian 11 on amd64.

ssh into your server and drop to root if not already with `su -` and enter the root password.

Update your server:

`apt update`

`apt full-upgrade -y`

Then install the packages we need for the installation and setup:

`apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot libmagic-dev`

### Optional packages

There are optional packages for media/processing: https://docs.akkoma.dev/stable/installation/optional/mediagraphicspackages/ I installed them all as it's not much space, and I wasn't sure which features I would be needing down the road. The base installation doesn't need them, but if you want to strip geolocation from images then you'd need `exiftool` for example.

To install:

`apt install imagemagick ffmpeg libimage-exiftool-perl`

If you feel the urge to configure PosgresSQL you can do so here

I don't bother, I run basically a single user instance, therefore I don't have to learn. This is a basic guide to get an instance up. Don't do crap here then complain to me that my guide screwed up your install. It didn't: YOU DID.

# The Installation

Create the Akkoma user

`adduser --system --shell /bin/false --home /opt/akkoma akkoma`

Set the flavour environment variable to the string you got in Detecting flavour section. For example if the flavour is `amd64` the command will be (which for our Linode, it is):

`export FLAVOUR="amd64"`

Clone the release build into a temporary directory and unpack it

`su akkoma -s $SHELL -lc "curl 'https://akkoma-updates.s3-website.fr-par.scw.cloud/stable/akkoma-$FLAVOUR.zip' -o /tmp/akkoma.zip unzip /tmp/akkoma.zip -d /tmp/"`

Move the release to the home directory and delete temporary files

`su akkoma -s $SHELL -lc "mv /tmp/release/* /opt/akkoma rmdir /tmp/release rm /tmp/akkoma.zip"`

Create uploads directory and set proper permissions (skip if planning to use a remote uploader)

Note: It does not have to be `/var/lib/akkoma/uploads`, the config generator will ask about the upload directory later (I just did this though as I did not see a reason not to)

`mkdir -p /var/lib/akkoma/uploads`

`chown -R akkoma /var/lib/akkoma`

Create custom public files directory (custom emojis, frontend bundle overrides, robots.txt, etc.)

Note: It does not have to be `/var/lib/akkoma/static`, the config generator will ask about the custom public files directory later

`mkdir -p /var/lib/akkoma/static`

`chown -R akkoma /var/lib/akkoma`

Create a config directory

`mkdir -p /etc/akkoma`

`chown -R akkoma /etc/akkoma`

Run the config generator

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/akkoma/config.exs --output-psql /tmp/setup_db.psql"`

This will ask a bunch of questions to set up the instance, like instance name and domain name etc. Pressing enter to use the defaults where it makes sense isn't a silly idea. :wink:

Once that is done, create the postgres database

`su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"`

Create the database schema

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl migrate"`

Start the instance to verify that everything is working as expected

`su akkoma -s $SHELL -lc "./bin/pleroma daemon"`

Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly

`sleep 20 && curl http://localhost:4000/api/v1/instance`

Stop the instance

`su akkoma -s $SHELL -lc "./bin/pleroma stop"`

## Set up Let's Encrypt SSL Certificates and nginx config

First, stop nginx so it won't hijack the connection

`systemctl stop nginx`

Then you can run the standalone certbot challenge which stands up it's own webserver. Replace `yourinstance.tld` with the domain you are using.

`certbot certonly --standalone --preferred-challenges http -d yourinstance.tld`

If you enabled ngingx again now you should see the default nginx landing page - but we'll wait until we've edited the nginx config.

The official guide source path is incorrect for the nginx config, below has the correct one at time of writing:

`cp /opt/akkoma/installation/akkoma.nginx /etc/nginx/sites-available/akkoma.conf`

Then enable the config

`ln -s /etc/nginx/sites-available/akkoma.conf /etc/nginx/sites-enabled/akkoma.conf`

Edit the nginx config for your domain using `nano`

`nano /etc/nginx/sites-available/akkoma.conf`

Press Ctrl+\ to search, type in `example.tld` then press Enter, then enter your (sub)domain for your instance, and Enter again. It will prompt, pres A for all occurances of `example.tld` to be replaced with your (sub)domain Ctrl+X to exit, Y to save, Enter to confirm filename (which remains the same). Clear as mud? Good.

Verify that the config is valid:

`nginx -t`

Now that certbot has run and the config has been set up for your instance, you can start nginx again

`systemctl start nginx`

## Set up the system service for Akkoma

Copy the supplied service file into the proper directory

`cp /opt/akkoma/installation/akkoma.service /etc/systemd/system/akkoma.service`

Start Akkoma and enable it on boot

`systemctl start akkoma`

`systemctl enable akkoma`

## Install a Front-End!

If you go to your instance in the browser now, you should see a page saying Akkoma is installed but there is no FE. As we are on a small VPS, we want a lightweight one, and PleromaFE fits the bill:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl frontend install pleroma-fe --ref stable"`

Unless you're a command line wizard, you'll probably want to install AdminFE also:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl frontend install admin-fe --ref stable"`

# Post Installation

We're not done yet... but we're so close, keep going!

## Set up auto-renew of Let's Encrypt certificate

Create the directory for webroot challenges

`mkdir -p /var/lib/letsencrypt`

Uncomment the webroot method in the nginx config (read the text inside `akkoma.conf`, it explains: remove the `#` from in front of those lines below the description)

`nano /etc/nginx/sites-available/akkoma.conf`

Then verify the config is still valid after your uncommenting that section:

`nginx -t`

If it isn't, go work out what you did wrong and fix it ;)

Restart nginx to load with the changes

`systemctl restart nginx`

Do a dry run to confirm the webroot method and post hook is working

`certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --dry-run --post-hook 'systemctl reload nginx'`

Add it to daily cron. Make sure you replace `example.tld` with the domain of your instance, or it won't renew (don't ask how I realised that)...

`echo '#!/bin/sh certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx"' > /etc/cron.daily/renew-akkoma-cert`

`chmod +x /etc/cron.daily/renew-akkoma-cert`

If everything worked the output should contain /etc/cron.daily/renew-akkoma-cert run-parts --test /etc/cron.daily

# Create your Admin User

Now we are getting to the fun stuff!

`cd /opt/akkoma`

The command:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl user new <nickname> <email> [option ...]"`

    --name <name> - the user's display name
    --bio <bio> - the user's bio
    --password <password> - the user's password
    --moderator/--no-moderator - whether the user should be a moderator
    --admin/--no-admin - whether the user should be an admin
    -y, --assume-yes/--no-assume-yes - whether to assume yes to all questions

So as an example:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl user new joeuser joeuser@sld.tld --admin"`

This will create an account withe the username of `joeuser` with the email address of `joeuser@sld.tld`, and set that user's account as an admin. This will result in a link writen in the terminal that you can copy and paste into the browser, which logs you in and enables you to set the password. Once you have done that, you're logged and it all works!

### Just a last couple of things though... almost done. I promise.

## Add email capability

You know, for email verification, or notices of reports etc. Now, this can probably all be added in AdminFE after the settings migration to DB... but I did it this way, so here we go.

If this is still here, I am useless Give me a poke on fedi reminding me to update this with a screenshot showing how to to it in AdminFE, as below doesnt work anyway.

> I had an issue of this not actually working. I ended up asking some folks with more experience than me who looked at a screenshot of the email settings in ADminFE and told me to turn off STARTTLS.

> And then it all just worked.

> I will update this when I work out the way to make it work first time.

`nano /etc/akkoma/config.exs`

Paste in below the other entries:

`config :pleroma, Pleroma.Emails.Mailer, enabled: true, adapter: Swoosh.Adapters.SMTP, relay: "smtp.emailprovider.com", username: "YOUR_USERNAME@emailprovider.com", password: "YOUR_SMTP_PASSWORD", port: 465, ssl: true, auth: :always`

Send Test email:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl email test --to root@example.org"`

Send confirmation emails to all unconfirmed user accounts:

`su akkoma -s $SHELL -lc " ./bin/pleroma_ctl email resend_confirmation_emails"`

see: https://docs.akkoma.dev/stable/configuration/cheatsheet/#email

## Migrate settings to DB...

...to enable changing settings in AdminFE instead of command line or files like some freakn wizard.

su akkoma -s $SHELL -lc "./bin/pleromactl config migrateto_db"`

see: https://docs.akkoma.dev/stable/administration/CLI_tasks/config/

# Useful notes:

## Updating your instance

I made a new post about updating which can now be found here

## Adding relays

Can be done in AdminFE, but have left here as it may be useful. Perhaps. \ If you import follows exported from another account, you probably don't need to add one.

Follow a relay:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl relay follow <relay_url>"`

Unfollow a relay:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl relay unfollow <relay_url>"`

List relay subscriptions:

`su akkoma -s $SHELL -lc "./bin/pleroma_ctl relay list"`

## Static Directory

This is where you store themes, emoji etc, that don't get overwritten during upgrades. as we are using the OTP version, it is: `/var/lib/akkoma/static/`

Tags: Akkoma, Linux, Fediverse, smolweb