Mastodon ist ein freies und dezentrales soziales Netzwerk, als Alternative zu Twitter. Es basiert auf offenen Web-Protokollen und freier, quelloffener Software. So installiert Ihr eure eigene Mastodon-Instanz unter Debian 9 Stretch.
Inhaltsverzeichnis
Voraussetzungen
- Keine
Abhängigkeiten installieren
test@social:~$ sudo apt -y install curl
test@social:~$ curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
test@social:~$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
test@social:~$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
test@social:~$ sudo apt update
test@social:~$ sudo apt -y install nodejs yarn imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git curl g++ libprotobuf-dev protobuf-compiler pkg-config build-essential libreadline-dev libicu-dev libidn11-dev libssl-dev libjemalloc-dev tmux postgresql postgresql-client libpq-dev postgresql-contrib redis-server dirmngr gawk autoconf automake bison libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool libyaml-dev sqlite3 libgmp-dev
Benutzer anlegen
test@social:~$ sudo adduser --gecos "Mastodon" --home /home/mastodon mastodon
test@social:~$ sudo usermod -aG www-data mastodon
Datenbank anlegen
test@social:~$ sudo -u postgres createuser mastodon -d -P -R
--> DB Passwort füe user mastodon setzen
Installation RVM
test@social:~$ sudo su - mastodon
mastodon@social:~$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
mastodon@social:~$ curl -sSL https://get.rvm.io | bash -s stable
mastodon@social:~$ source /home/mastodon/.rvm/scripts/rvm
mastodon@social:~$ rvm install 2.5.1
mastodon@social:~$ rvm use 2.5.1
Mastodon klonen
mastodon@social:~$ cd ~
mastodon@social:~$ git clone https://github.com/tootsuite/mastodon.git live
mastodon@social:~$ cd live
mastodon@social:~/live$ git checkout v2.4.3
Installation Mastodon
mastodon@social:~/live$ gem install bundler
mastodon@social:~/live$ bundle install --deployment --without development test
mastodon@social:~/live$ yarn install
Konfiguration Mastodon
mastodon@social:~/live$ RAILS_ENV=production bundle exec rake mastodon:setup
mastodon@social:~/live$ exit
Systemdienste Konfiguration
test@social:~$ sudo vim.tiny /etc/systemd/system/mastodon-web.service
[Unit]
Description=mastodon-web
After=network.target
[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="RAILS_ENV=production"
Environment="PORT=3000"
ExecStart=/home/mastodon/.rvm/gems/ruby-2.5.1/wrappers/bundle exec puma -C config/puma.rb
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
test@social:~$ sudo vim.tiny /etc/systemd/system/mastodon-sidekiq.service
[Unit]
Description=mastodon-sidekiq
After=network.target
[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="RAILS_ENV=production"
Environment="DB_POOL=5"
ExecStart=/home/mastodon/.rvm/gems/ruby-2.5.1/wrappers/bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
test@social:~$ sudo vim.tiny /etc/systemd/system/mastodon-streaming.service
[Unit]
Description=mastodon-streaming
After=network.target
[Service]
Type=simple
User=mastodon
WorkingDirectory=/home/mastodon/live
Environment="NODE_ENV=production"
Environment="PORT=4000"
ExecStart=/usr/bin/npm run start
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
Systemdienste einrichten
test@social:~$ sudo ln -s /etc/systemd/system/mastodon-web.service /etc/systemd/system/multi-user.target.wants/mastodon-web.service
test@social:~$ sudo ln -s /etc/systemd/system/mastodon-sidekiq.service /etc/systemd/system/multi-user.target.wants/mastodon-sidekiq.service
test@social:~$ sudo ln -s /etc/systemd/system/mastodon-streaming.service /etc/systemd/system/multi-user.target.wants/mastodon-streaming.service
Nun kann Mastodon durch:
test@social:~$ sudo systemctl start mastodon-web.service
test@social:~$ sudo systemctl start mastodon-sidekiq.service
test@social:~$ sudo systemctl start mastodon-streaming.service
gestartet werden.
Installation & Konfiguration Apache
test@social:~$ sudo apt -y install apache2
test@social:~$ sudo a2enmod ssl proxy proxy_wstunnel proxy_http headers
test@social:~$ sudo service apache2 restart
vHost Konfiguration
test@social:~$ sudo vim.tiny /etc/apache2/sites-available/social.test.local.conf
<VirtualHost *:80>
ServerAdmin
ServerName social.dev.local
Redirect Permanent / https://social.dev.local/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin
ServerName social.dev.local
DocumentRoot /home/mastodon/live/public/
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Strict-Transport-Security "max-age=31536000"
SSLEngine on
SSLProtocol -all +TLSv1.2
SSLHonorCipherOrder on
SSLCipherSuite EECDH+AESGCM:AES256+EECDH:AES128+EECDH
SSLCompression off
SSLSessionTickets off
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off
SSLUseStapling off
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<LocationMatch "^/(assets|avatars|emoji|headers|packs|sounds|system)>
Header always set Cache-Control "public, max-age=31536000, immutable"
Require all granted
</LocationMatch>
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "https"
ProxyPass /500.html !
ProxyPass /sw.js !
ProxyPass /robots.txt !
ProxyPass /manifest.json !
ProxyPass /browserconfig.xml !
ProxyPass /mask-icon.svg !
ProxyPassMatch ^(/.*\.(png|ico)$) !
ProxyPassMatch ^/(assets|avatars|emoji|headers|packs|sounds|system|.well-known/acme-challenge) !
ProxyPass /api/v1/streaming/ ws://localhost:4000/
ProxyPassReverse /api/v1/streaming/ ws://localhost:4000/
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ErrorDocument 500 /500.html
ErrorDocument 501 /500.html
ErrorDocument 502 /500.html
ErrorDocument 503 /500.html
ErrorDocument 504 /500.html
</VirtualHost>
Die vhost Seite aktivieren und apache neu laden:
test@social:~$ sudo a2ensite social.dev.local.conf
test@social:~$ sudo systemctl reload apache2
Abschluss
Damit ist unser Tutorial zu "Mastodon - Installation auf Debian Stretch" abgeschlossen. Wenn Sie Fragen haben, senden Sie eine Mail an: