Mastodon

How to install Mastodon ActivityPub server on FreeBSD.

Installation Procedure

Install Dependencies

Configure Nginx Web Server

Add the following inside the http block of /usr/local/etc/nginx/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.

Enable nginx on startup and start nginx:

Configure SSL certificates with acme.sh

Configure PostgreSQL DB Server

Enable postgresql on startup, initial databases and start postgresql:

   1 sysrc postgresql_enable="YES"
   2 service postgresql initdb
   3 service postgresql start

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:

   1 sysrc redis_enable="YES"
   2 service redis start

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:

   1 sysrc mastodon_sidekiq_enable=YES
   2 sysrc mastodon_streaming_enable=YES
   3 sysrc mastodon_web_enable=YES
   4 service mastodon_sidekiq start
   5 service mastodon_streaming start
   6 service mastodon_web start

Upgrade Procedure - 4.0.2=>4.1.0

Stop the services

   1 service mastodon_sidekiq stop
   2 service mastodon_streaming stop
   3 service mastodon_web stop

Upgrade the packages

   1 pkg upgrade -y

Upgrade the rubygems and assets

   1 su -l mastodon
   2 cd
   3 bundle install -j$(getconf _NPROCESSORS_ONLN)
   4 yarn install --pure-lockfile
   5 RAILS_ENV=production bundle exec rails db:migrate
   6 RAILS_ENV=production bundle exec rake tmp:cache:clear
   7 RAILS_ENV=production bundle exec rails assets:precompile
   8 exit

Restart the services

   1 service -R

References & Resources


CategoryHowTo CategoryPorts

Ports/net-im/mastodon (last edited 2023-11-22T11:07:50+0000 by MuhammadMoinurRahman)