MASTODON 3.5.X/4.1.x -- DEBIAN 11/12 -- LAN TEST INSTALLATION (NOT FOR PRODUCTION!)
# ln -s /usr/bin/yarnpkg /usr/local/bin/yarn
# apt install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev \
git-core g++ libprotobuf-dev protobuf-compiler pkg-config \
nodejs gcc autoconf bison build-essential libssl-dev \
libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev \
libffi-dev libgdbm-dev nginx redis-server redis-tools \
postgresql postgresql-contrib libidn11-dev libicu-dev \
libjemalloc-dev yarnpkg curl gnupg postfix bsd-mailx
# su -c psql postgres
> CREATE USER mastodon CREATEDB;
> \q
# useradd -m -s /bin/bash -u 7007 -U mastodon
# su -l mastodon
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv && cd ~/.rbenv
$ src/configure && make -C src
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec bash
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.6
$ rbenv global 3.0.6
$ gem install bundler --no-document
$ git clone https://github.com/mastodon/mastodon.git ~/live && cd live
$ git checkout "$(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)"
$ bundle config deployment 'true'
$ bundle config without 'development test'
$ bundle install -j"$(nproc)"
$ yarnpkg set version 1
$ yarnpkg install --pure-lockfile
$ RAILS_ENV=production bundle exec rake mastodon:setup
$ exit
# cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon
# ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon
# editor /etc/nginx/sites-available/mastodon
> Replace example.com and disable HSTS header!
> ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
> ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
# service nginx reload
# cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
# editor /etc/systemd/system/mastodon-*.service
> ExecStart=/usr/bin/bundle ...
# systemctl daemon-reload
# systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming