I am fairly new at this, but if you want to explore the idea, the easiest way, I think, is to install Yunohost on an old unused computer.
Through #yunohost you can easily install Mastodon and/or Pixelfed.
If you want to read about this, @_elena has written (enthousiasticaly) about her experience in #selfhosting : https://news.elenarossini.com/