Table of Contents
I used the instructions from Mastodon and adopted it to fit better for me :)
Install Mastodon on Rocky Linux 9
Pre-requisites
Enable EPEL is a good idea
dnf config-manager --set-enabled powertools dnf install epel-release
Get the YARN repo
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
Installing the needed packages
yum install -y git ruby ruby-devel postgresql-devel postgresql-server postgresql \ postgresql-contrib nodejs.x86_64 yarn make idn2.x86_64 libidn-devel.x86_64 \ libidn2-devel.x86_64 libidn.x86_64 libicu-devel.x86_64 libicu.x86_64 gcc gcc-c++ \ libzstd-devel openssl-devel tar redis nginx certbot.noarch \ python3-certbot-nginx.noarch ImageMagick.x86_64 libicu-devel.x86_64 postgresql-contrib.x86_64 \ libffi-devel.x86_64 libyaml.x86_64 autoconf.noarch protobuf.x86_64 \ libxml2-devel.x86_64 bison.x86_64 libpq-devel.x86_64 jemalloc-devel rbenv
Add the user and change the home-dir
adduser mastodon mv /home/mastodon /opt usermod -d /opt/mastodon mastodon
Start redis
systemctl enable --now redis
Preparing the DB
systemctl start postgresql.service /usr/bin/postgresql-setup --initdb --unit postgresql sudo -u postgres psql
CREATE USER mastodon CREATEDB; \q
Setting up Mastodon
su - mastodon
Use git to download the latest stable release of Mastodon:
git clone https://github.com/tootsuite/mastodon.git live && cd live git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
Now to install Ruby and JavaScript dependencies:
bundle config deployment 'true' bundle config without 'development test' bundle install -j$(getconf _NPROCESSORS_ONLN) yarn install --pure-lockfile
Run the interactive setup wizard:
RAILS_ENV=production bundle exec rake mastodon:setup
Setting up nginx
Copy the prepared nginx.conf into the nginxc config-dir. Change the hostname and the root-dir.
cp /opt/mastodon/live/dist/nginx.conf /etc/nginx/conf.d/mastodon.conf sed -i 's:/home/mastodon/live/public;:/opt/mastodon/live/public;:g' /etc/nginx/conf.d/mastodon.conf sed -i 's/example.com/social.server17.net/g' /etc/nginx/conf.d/mastodon.conf
Ensure that the firewall is configured for http and https
firewall-cmd --add-service=http --permanent firewall-cmd --add-service=https --permanent firewall-cmd --reload
Get a certifcate for your host/hostname
certbot --nginx -d social.server17.net
Setting up systemd services
copy the files
cp /opt/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
and edit the files
sed -i 's:/home/mastodon/:/opt/mastodon/:g' /etc/systemd/system/mastodon-* sed -i 's:/opt/mastodon/.rbenv/shims/bundle:/opt/mastodon/live/bin/bundle:g' /etc/systemd/system/mastodon-*
now relaod the systemd and start evertything
systemctl daemon-reload systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming
Maybe something went wrong with the install of the bundler gem and the services are not starting. Check if the gem is installed or just install it.
# su - mastodon cd live/ RAILS_ENV=production gem install bundler
Tuning
Start tuning sidekiq
sidekiq is handling multiple queues. Each of them can run as an own process. Per process you should use a max. of 25 threads.
OLD HOW TO
Install Mastodon on Rocky Linux 8
Pre-requisites
Enable EPEL is a good idea
dnf config-manager --set-enabled powertools dnf install epel-release
Get the YARN repo
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
After a fresh installation, setting some software to the needed release.
yum module enable ruby:3.0 -y yum module enable nodejs:12 -y yum module enable postgresql:12 -y
Installing the needed packages
yum install -y git ruby ruby-devel postgresql-devel postgresql-server postgresql \ postgresql-contrib nodejs.x86_64 yarn make idn2.x86_64 libidn-devel.x86_64 \ libidn2-devel.x86_64 libidn.x86_64 libicu-devel.x86_64 libicu.x86_64 gcc gcc-c++ \ libzstd-devel openssl3-devel openssl-devel tar redis nginx certbot.noarch \ python3-certbot-nginx.noarch ImageMagick.x86_64 libicu-devel.x86_64 postgresql-contrib.x86_64 \ libffi-devel.x86_64 libyaml-devel.x86_64 autoconf.noarch protobuf-compiler.x86_64 \ libxml2-devel.x86_64 bison.x86_64 libpq-devel.x86_64 jemalloc-devel rbenv
Add the user and change the home-dir
adduser mastodon mv /home/mastodon /opt usermod -d /opt/mastodon mastodon
Preparing the DB
systemctl start postgresql.service /usr/bin/postgresql-setup --initdb --unit postgresql sudo -u postgres psql
CREATE USER mastodon CREATEDB; \q
Setting up Mastodon
su - mastodon
Use git to download the latest stable release of Mastodon:
git clone https://github.com/tootsuite/mastodon.git live && cd live git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
Now to install Ruby and JavaScript dependencies:
bundle config deployment 'true' bundle config without 'development test' bundle install -j$(getconf _NPROCESSORS_ONLN) yarn install --pure-lockfile
Run the interactive setup wizard:
RAILS_ENV=production bundle exec rake mastodon:setup
Setting up nginx
Copy the prepared nginx.conf into the nginxc config-dir. Change the hostname and the root-dir.
cp /opt/mastodon/live/dist/nginx.conf /etc/nginx/conf.d/mastodon.conf sed -i 's:/home/mastodon/live/public;:/opt/mastodon/live/public;:g' /etc/nginx/conf.d/mastodon.conf sed -i 's/example.com/social.server17.net/g' /etc/nginx/conf.d/mastodon.conf
Ensure that the firewall is configured for http and https
firewall-cmd --add-service=http --permanent firewall-cmd --add-service=https --permanent firewall-cmd --reload
Get a certifcate for your host/hostname
certbot --nginx -d social.server17.net
Setting up systemd services
copy the files
cp /opt/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
and edit the files
sed -i 's:/home/mastodon/:/opt/mastodon/:g' /etc/systemd/system/mastodon-* sed -i 's:/opt/mastodon/.rbenv/shims/bundle:/bin/bundle:g' mastodon-*
now relaod the systemd and start evertything
systemctl daemon-reload systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming
Update Mastodon to 4.0.*
That is just a how-to which worked for me. Do a Backup in advance!
Pre-requisites
Backup everything! You do not want to stay up half of the night and fix something.
With the update to the version 4.0 you need a nodejs 14 and also edit some path in the system files.
Update nodejs:
yum module reset nodejs yum module enable nodejs:14 yum -y update
Edit the path for bundle:
sed -i 's:ExecStart=/bin/bundle:ExecStart=/opt/mastodon/bin/bundle:g' /etc/systemd/system/mastodon-*
That is necessary, because in my installation I changed it before.
the REAL update
Here I just followed the manual from Mastodon on Github.
This can take some minutes:
su - mastodon cd live git fetch && git checkout v4.0.0 bundle install yarn install
Also this take some minutes
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate RAILS_ENV=production bundle exec rails assets:precompile sudo systemctl restart mastodon-* RAILS_ENV=production bundle exec rails db:migrate sudo systemctl restart mastodon-*
Update to 4.0.2
su - mastodon cd live git fetch && git checkout v4.0.2 bundle install RAILS_ENV=production bundle exec rails assets:precompile sudo systemctl restart mastodon-*
YEAH! Welcome to the new version.
Tuning
Start tuning sidekiq
sidekiq is handling multiple queues. Each of them can run as an own process. Per process you should use a max. of 25 threads.
