2021-05-16 17:20:20 +00:00
# Installing on FreeBSD
2020-08-06 04:01:57 +00:00
2020-08-14 04:21:42 +00:00
This document was written for FreeBSD 12.1, but should be work on future releases.
2020-08-06 04:01:57 +00:00
2021-06-11 06:43:36 +00:00
{! backend/installation/generic_dependencies.include !}
## Installing software used in this guide
2020-08-06 04:01:57 +00:00
This assumes the target system has `pkg(8)` .
2020-08-14 04:21:42 +00:00
```
2020-09-26 16:32:16 +00:00
# pkg install elixir postgresql12-server postgresql12-client postgresql12-contrib git-lite sudo nginx gmake acme.sh cmake
2020-08-14 04:21:42 +00:00
```
2020-08-06 04:01:57 +00:00
Copy the rc.d scripts to the right directory:
Setup the required services to automatically start at boot, using `sysrc(8)` .
```
# sysrc nginx_enable=YES
# sysrc postgresql_enable=YES
```
## Initialize postgres
```
# service postgresql initdb
# service postgresql start
```
2021-01-10 08:25:36 +00:00
### Install media / graphics packages (optional, see [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md))
2020-09-26 16:32:16 +00:00
```shell
# pkg install imagemagick ffmpeg p5-Image-ExifTool
```
2022-07-02 21:00:01 +00:00
## Configuring Akkoma
2020-08-06 04:01:57 +00:00
2022-07-02 21:00:01 +00:00
Create a user for Akkoma:
2020-08-06 04:01:57 +00:00
```
2022-07-02 21:00:01 +00:00
# pw add user akkoma -m
# echo 'export LC_ALL="en_US.UTF-8"' >> /home/akkoma/.profile
# su -l akkoma
2020-08-06 04:01:57 +00:00
```
Clone the repository:
```
2022-07-02 21:00:01 +00:00
$ cd $HOME # Should be the same as /home/akkoma
$ git clone https://akkoma.dev/AkkomaGang/akkoma.git
2020-08-06 04:01:57 +00:00
```
2022-07-02 21:00:01 +00:00
Configure Akkoma. Note that you need a domain name at this point:
2020-08-06 04:01:57 +00:00
```
2022-07-02 21:00:01 +00:00
$ cd /home/akkoma/akkoma
2020-08-13 23:34:04 +00:00
$ mix deps.get # Enter "y" when asked to install Hex
2021-05-16 17:20:20 +00:00
$ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
2020-08-14 04:21:42 +00:00
$ cp config/generated_config.exs config/prod.secret.exs
2020-08-06 04:01:57 +00:00
```
Since Postgres is configured, we can now initialize the database. There should
now be a file in `config/setup_db.psql` that makes this easier. Edit it, and
*change the password* to a password of your choice. Make sure it is secure, since
it'll be protecting your database. As root, you can now initialize the database:
```
2022-07-02 21:00:01 +00:00
# cd /home/akkoma/akkoma
2020-08-06 04:01:57 +00:00
# sudo -Hu postgres -g postgres psql -f config/setup_db.psql
```
Postgres allows connections from all users without a password by default. To
fix this, edit `/var/db/postgres/data12/pg_hba.conf` . Change every `trust` to
`password` .
2020-08-14 04:21:42 +00:00
Once this is done, restart Postgres with:
```
# service postgresql restart
```
2020-08-06 04:01:57 +00:00
Run the database migrations.
2022-07-02 21:00:01 +00:00
Back as the akkoma user, run the following to implement any database migrations.
2020-08-06 04:01:57 +00:00
```
2022-07-02 21:00:01 +00:00
# su -l akkoma
$ cd /home/akkoma/akkoma
2020-08-06 04:01:57 +00:00
$ MIX_ENV=prod mix ecto.migrate
```
2020-08-06 23:24:12 +00:00
You will need to do this whenever you update with `git pull` :
2020-08-14 00:58:46 +00:00
## Configuring acme.sh
2020-08-06 04:01:57 +00:00
2020-08-14 00:58:46 +00:00
We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
2020-08-06 04:01:57 +00:00
2020-08-14 00:58:46 +00:00
First, as root, allow the user `acme` to have access to the acme log file, as follows:
2020-08-06 04:01:57 +00:00
```
2020-08-14 00:58:46 +00:00
# touch /var/log/acme.sh.log
# chown acme:acme /var/log/acme.sh.log
# chmod 600 /var/log/acme.sh.log
2020-08-06 04:01:57 +00:00
```
2020-08-14 00:58:46 +00:00
Next, obtain your account fingerprint:
2020-08-06 04:01:57 +00:00
```
2020-08-13 23:08:13 +00:00
# sudo -Hu acme -g acme acme.sh --register-account
2020-08-06 04:01:57 +00:00
```
You need to add the following to your nginx configuration for the server
running on port 80:
```
location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
default_type text/plain;
return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
}
```
Replace the string after after `$1.` with your fingerprint.
Start nginx:
```
# service nginx start
```
It should now be possible to issue a cert (replace `example.com`
with your domain name):
```
2020-08-14 01:24:08 +00:00
# sudo -Hu acme -g acme acme.sh --issue -d example.com --stateless
2020-08-06 04:01:57 +00:00
```
2020-08-14 02:18:33 +00:00
Let's add auto-renewal to `/etc/crontab`
2020-08-06 04:01:57 +00:00
(replace `example.com` with your domain):
```
2020-08-14 02:18:33 +00:00
/usr/local/bin/sudo -Hu acme -g acme /usr/local/sbin/acme.sh -r -d example.com --stateless
2020-08-06 04:01:57 +00:00
```
2020-08-14 00:58:46 +00:00
### Configuring nginx
FreeBSD's default nginx configuration does not contain an include directive, which is
typically used for multiple sites. Therefore, you will need to first create the required
directory as follows:
```
# mkdir -p /usr/local/etc/nginx/sites-available
```
Next, add an `include` directive to `/usr/local/etc/nginx/nginx.conf` , within the `http {}`
block, as follows:
```
http {
...
2020-08-14 02:38:23 +00:00
include /usr/local/etc/nginx/sites-available/*;
2020-08-14 00:58:46 +00:00
}
```
2022-07-06 18:50:01 +00:00
As root, copy `/home/akkoma/akkoma/installation/nginx/akkoma.nginx` to
2022-07-02 21:00:01 +00:00
`/usr/local/etc/nginx/sites-available/akkoma.nginx` .
2020-08-14 00:58:46 +00:00
2022-07-02 21:00:01 +00:00
Edit the defaults of `/usr/local/etc/nginx/sites-available/akkoma.nginx` :
2020-08-14 00:58:46 +00:00
2020-08-14 04:21:42 +00:00
* Change `ssl_trusted_certificate` to `/var/db/acme/certs/example.tld/example.tld.cer` .
* Change `ssl_certificate` to `/var/db/acme/certs/example.tld/fullchain.cer` .
* Change `ssl_certificate_key` to `/var/db/acme/certs/example.tld/example.tld.key` .
2020-08-14 00:58:46 +00:00
* Change all references of `example.tld` to your instance's domain name.
2022-07-02 21:00:01 +00:00
## Creating a startup script for Akkoma
2020-08-06 04:01:57 +00:00
2022-07-02 21:00:01 +00:00
Akkoma will need to compile when it initially starts, which typically takes a longer
period of time. Therefore, it is good practice to initially run akkoma from the
2020-08-06 04:01:57 +00:00
command-line before utilizing the rc.d script. That is done as follows:
```
2022-07-02 21:00:01 +00:00
# su -l akkoma
$ cd $HOME/akkoma
2020-08-06 04:01:57 +00:00
$ MIX_ENV=prod mix phx.server
```
Copy the startup script to the correct location and make sure it's executable:
```
2022-07-02 21:00:01 +00:00
# cp /home/akkoma/akkoma/installation/freebsd/rc.d/akkoma /usr/local/etc/rc.d/akkoma
# chmod +x /usr/local/etc/rc.d/akkoma
2020-08-06 04:01:57 +00:00
```
2022-07-02 21:00:01 +00:00
Update the `/etc/rc.conf` and start akkoma with the following commands:
2020-08-06 04:01:57 +00:00
```
2022-07-02 21:00:01 +00:00
# sysrc akkoma_enable=YES
# service akkoma start
2020-08-06 04:01:57 +00:00
```
2020-08-14 04:21:42 +00:00
#### Create your first user
If your instance is up and running, you can create your first user with administrative rights with the following task:
```shell
2022-07-02 21:00:01 +00:00
sudo -Hu akkoma MIX_ENV=prod mix pleroma.user new < username > < your @ emailaddress > --admin
2020-08-14 04:21:42 +00:00
```
2020-08-06 04:01:57 +00:00
## Conclusion
2020-08-07 01:52:39 +00:00
Restart nginx with `# service nginx restart` and you should be up and running.
2020-08-06 04:01:57 +00:00
Make sure your time is in sync, or other instances will receive your posts with
incorrect timestamps. You should have ntpd running.
## Questions
2022-07-02 21:00:01 +00:00
If you encounter any issues or have questions regarding the install process, feel free to ask at [meta.akkoma.dev ](https://meta.akkoma.dev/ ).