Mastodon
How to install Mastodon ActivityPub server on FreeBSD.
Installation Procedure
Install Dependencies
1 pkg install -y nginx acme.sh postgresql13-server mastodon
Configure Nginx Web Server
Add the following inside the http block of /usr/local/etc/nginx/nginx.conf
1 include /usr/local/www/mastodon/dist/nginx.conf;
Update Nginx configuration:
Note: The mastodon/dist/nginx.conf was originally provided by the www/mastodon package. It will need to be created.
1 sed -i '' -e 's/example.com/<YOUR DESIRED DOMAIN>/g' /usr/local/www/mastodon/dist/nginx.conf
Enable nginx on startup and start nginx:
Configure SSL certificates with acme.sh
1 mkdir -p /usr/local/etc/ssl/<YOUR DESIRED DOMAIN> 2 acme.sh --issue --webroot /usr/local/www/mastodon/public -d <YOUR DESIRED DOMAIN> 3 acme.sh --install-cert -d <YOUR DESIRED DOMAIN> --cert-file /usr/local/etc/ssl/<YOUR DESIRED DOMAIN>/cert.pem --key-file /usr/local/etc/ssl/<YOUR DESIRED DOMAIN>/key.pem --ca-file /usr/local/etc/ssl/<YOUR DESIRED DOMAIN>/ca.pem --fullchain-file /usr/local/etc/ssl/<YOUR DESIRED DOMAIN>/fullchain.pem --reloadcmd 'service nginx restart'
Configure PostgreSQL DB Server
Enable postgresql on startup, initial databases and start postgresql:
Create a new role for the mastodon database:
1 su -l postgres -c 'createuser -d mastodon'
Configure Redis Server
Enable redis on startup and start redis:
In case mastodon is run in a jail; protected-mode should be disabled in /usr/local/etc/redis.conf
Configure Mastodon
File permissions is an important factor for a working copy of Mastodon so let's switch to the dedicated mastodon user and run the installations:
1 su -l mastodon
2 cd
3 yarn set version classic
4 bundle config deployment 'true'
5 bundle config without 'development test'
6 bundle config build.cbor --with-cflags="-Wno-incompatible-function-pointer-types" (Needed for 13.2-STABLE and 14.0-RELEASE and later)
7 bundle config build.posix-spawn --with-cflags="-Wno-incompatible-function-pointer-types" (Needed for 13.2-STABLE and 14.0-RELEASE and later)
8 bundle install -j$(getconf _NPROCESSORS_ONLN)
9 yarn install --pure-lockfile
On the next step let's install and configure the Mastodon system still as the mastodon user.
When asked for Postgresql instance it's better to use 127.0.0.1 rather than localhost or sockets.
1 RAILS_ENV=production bundle exec rake mastodon:setup
Enable the services at startup and start the services:
Upgrade Procedure - 4.0.2=>4.1.0
Stop the services
Upgrade the packages
1 pkg upgrade -y
Upgrade the rubygems and assets
Restart the services
1 service -R
References & Resources
Mastodon on FreeBSD Notes (GitHub: jsm222 (JesperMouridsen), 2022-11-29)
Stefano Marinelli: Installing Mastodon inside a FreeBSD jail using BastilleBSD (it-notes.dragas.net, 2022-11-23)
BastilleBSD template to bootstrap Mastodon in a FreeBSD jail (github.com: ddowse, 2022-11-23)
Installer Mastodon sous FreeBSD (sans le port) (blog.gegeweb.org, French, 2018-06-17)