Here's a good intro to the topic (not that I personally have put it into practice) https://runyourown.social/

It focuses on Mastodon but that's probably an artifact of when it was written.