For example, the LAMP stack is sufficient to self-host blogs (Wordpress). What stack and architecture would be needed to recreate the basic functionality of Facebook (posts, photos, videos, and messages)?
The technical stack matters very little: you can do the necessary things with almost any webdev stack.<p>IMHO, federation is important if you want to replace Facebook and not just build a small-scale hub (which is a totally valuable thing to do too!), and for that you're going to need common protocols. Mastodon gets a lot of it right for making a Twitter-like, but there is no reason you couldn't build a Facebook-like on the same protocols (ActivityPub) too.