====== Mastodon ====== How to install Mastodon [[/ActivityPub|ActivityPub]] server on %%FreeBSD%%. ===== Installation Procedure ===== ==== Install Dependencies ==== 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%%'' 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. sed -i '' -e 's/example.com//g' /usr/local/www/mastodon/dist/nginx.conf Enable nginx on startup and start nginx: sysrc nginx_enable="YES" service nginx start === Configure SSL certificates with acme.sh === mkdir -p /usr/local/etc/ssl/ acme.sh --issue --webroot /usr/local/www/mastodon/public -d acme.sh --install-cert -d --cert-file /usr/local/etc/ssl//cert.pem --key-file /usr/local/etc/ssl//key.pem --ca-file /usr/local/etc/ssl//ca.pem --fullchain-file /usr/local/etc/ssl//fullchain.pem --reloadcmd 'service nginx restart' ==== Configure PostgreSQL DB Server ==== Enable postgresql on startup, initial databases and start postgresql: sysrc postgresql_enable="YES" service postgresql initdb service postgresql start Create a new role for the mastodon database: su -l postgres -c 'createuser -d mastodon' ==== Configure Redis Server ==== Enable redis on startup and start redis: sysrc redis_enable="YES" 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: su -l mastodon cd yarn set version classic bundle config deployment 'true' bundle config without 'development test' bundle install -j$(getconf _NPROCESSORS_ONLN) 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. RAILS_ENV=production bundle exec rake mastodon:setup Enable the services at startup and start the services: sysrc mastodon_sidekiq_enable=YES sysrc mastodon_streaming_enable=YES sysrc mastodon_web_enable=YES service mastodon_sidekiq start service mastodon_streaming start service mastodon_web start ===== Upgrade Procedure - 4.0.2=>4.1.0 ===== ==== Stop the services ==== service mastodon_sidekiq stop service mastodon_streaming stop service mastodon_web stop ==== Upgrade the packages ==== pkg upgrade -y ==== Upgrade the rubygems and assets ==== su -l mastodon cd bundle install -j$(getconf _NPROCESSORS_ONLN) yarn install --pure-lockfile RAILS_ENV=production bundle exec rails db:migrate RAILS_ENV=production bundle exec rake tmp:cache:clear RAILS_ENV=production bundle exec rails assets:precompile exit ==== Restart the services ==== service -R ===== References & Resources ===== * [[https://gist.github.com/jsm222/df6bb7c045859cf1972015e78ad4cc4b|Mastodon on FreeBSD Notes]] ([[/GitHub|GitHub]]: jsm222 ([[/JesperMouridsen|JesperMouridsen]]), 2022-11-29) * [[https://it-notes.dragas.net/2022/11/23/installing-mastodon-on-a-freebsd-jail/|Stefano Marinelli: Installing Mastodon inside a FreeBSD jail using BastilleBSD]] (it-notes.dragas.net, 2022-11-23) * [[https://github.com/ddowse/mastodon|BastilleBSD template to bootstrap Mastodon in a FreeBSD jail]] (github.com: ddowse, 2022-11-23) * [[https://blog.gegeweb.org/installer-mastodon-sous-freebsd-sans-le-port.html|Installer Mastodon sous FreeBSD (sans le port)]] (blog.gegeweb.org, French, 2018-06-17) ---- {{tag>HowTo Ports}}