Check out my first novel, midnight's simulacra!
Mastodon: Difference between revisions
Line 33: | Line 33: | ||
* Set up LetsEncrypt: <tt>certbot certonly --apache -d FQDN</tt> | * Set up LetsEncrypt: <tt>certbot certonly --apache -d FQDN</tt> | ||
* Prepare non-TLS upgrade config: | * Prepare non-TLS upgrade config: try [https://gist.github.com/dankamongmen/529de45dc4dff3835f272ca5d3fd430e something like this] | ||
* Prepare TLS proxy config: try [https://gist.github.com/dankamongmen/3bd66ec624a683f2c2be9ce7ab86a63b something like this] | * Prepare TLS proxy config: try [https://gist.github.com/dankamongmen/3bd66ec624a683f2c2be9ce7ab86a63b something like this] | ||
* <tt>sudo a2ensite mastodon-ssl</tt> | * <tt>sudo a2ensite mastodon-ssl</tt> |
Revision as of 07:50, 10 January 2021
Setting up a Masotdon server on Debian is somewhat annoying, due to the node- and ruby-based implementation. Most guides involve downloading and installing a large number of sources outside of APT. There's little need for such vulgarisms.
My running install uses the 3.2 branch of Mastodon atop Debian Unstable.
First, determine your domain name. You'll likely be serving Mastodon as a virtual host in your main nginx/apache config, so give it its own, distinct FQDN. It is not trivial to change your server's name later (it will, at a minimum, break existing federations), so choose wisely.
System work
- Via APT, install nodejs, redis-server, ruby-redis, rake, rbenv, ruby-bundler, postgresql-contrib, libpq-dev, libprotobuf-dev, protobuf-compiler, libidn11-dev, and yarnpkg ("yarn").
- You will now have a PostgreSQL instance running on localhost:tcp/5432, if you didn't before.
- You will now have a Redis instance running on localhost:tcp/6379, if you didn't before.
- So far as I can tell, you must now symlink /usr/bin/yarnpkg to yarn in some PATH directory 🤮:
- ln -s /usr/bin/yarnpkg /usr/local/bin/yarn
- Prep the database:
- echo "CREATE USER mastodon CREATEDB;" | sudo -u postgres psql
- Create mastodon user (salt to taste):
- sudo adduser --disabled-login --gecos "Mastodon service account" mastodon
User work
Remaining work will be done as the mastodon user, in its home directory.
- git clone https://github.com/tootsuite/mastodon.git ~/live
- cd live
- bundle config set --local deployment true
- bundle config set --local without development:test
- bundle install
- RAILS_ENV=production bundle exec rake mastodon:setup
- Use the same PostgreSQL user name you created earlier.
- So far as I can tell, use a blank password for PostgresQDL and Redis.
- I do (n)ot upload files to the "cloud", whatever that even means
- You are (n)ot running in a Docker (presumably)
Webserver work
Most guides assume you're running nginx. My directions assume Apache.
- Set up LetsEncrypt: certbot certonly --apache -d FQDN
- Prepare non-TLS upgrade config: try something like this
- Prepare TLS proxy config: try something like this
- sudo a2ensite mastodon-ssl
- sudo a2ensite mastodon
- sudo a2enmod proxy_http (if not already enabled)
- sudo systemctl restart apache2
Start it
- sudo cp ~mastodon/live/dist/*service /etc/systemd/system
- for in in web sidekiq streaming ; do sudo systemctl start mastodon-$i ; done
- Check the status of all three units with systemctl status and, if necessary, journalctl
- You ought have a node process listening on port 4000
- If good, for in in web sidekiq streaming ; do sudo systemctl enable mastodon-$i ; done
- The units are now persistent, and ought start at system boot
Full text search
If you're willing to run Java and a potentially-dodgy elasticsearch package (or build it from source), you can have full text search. Building from source is normally a pleasant endeavor, but who wants to fuck with gradle and all it implies?
- sudo apt-get install default-jre-headless
- apt-key adv --fetch-keys https://artifacts.elastic.co/GPG-KEY-elasticsearch
- echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
- sudo apt-get update && sudo apt-get install elasticsearch
- Add the following to .env.production:
ES_ENABLED=true ES_HOST=localhost ES_PORT=9200
- Restart mastodon-sidekiq and mastodon-web units
- RAILS_ENV=production bin/tootctl search deploy