Was he friendly prior to this? From the pups I've raised, they can get stranger-danger-y about 4-5 months old, but not if they are super social and confident from the get go. It's not really a phase that passes, it's part of his temperament and something you'll have to work with.
I personally don't like it, but I've certainly been through it, and made it out with a dog who was neutral, but not "social" in public.
It's something I correct, even in a pup, but that's so nuanced I won't get into it in writing. If you can find an experienced** trainer to help, now is the best time to start addressing this. It might go away, but I highly doubt it will, so you need to figure out how best to manage your dog.
Don't let him experience bad reactions to people again and again. That is in essence "training" this behavior. Treats might work, walking by fast, or engaging with a toy helps, but all those break down unless you can make it clear that the reactive-defensive behavior is not acceptable. I ended up doing this rather by accident with my pup years ago and it opened up a whole new understanding of training.
This is a great point, and I too try to stay away from describing corrections in writing, because people often misunderstand or misinterpret; and it's all about the timing, so it's really best to have someone experienced help you with that!
Personally, though, I treat reactivity similarly to most other training, in that I use a quiet "no" as a negative marker when the pup does something I don't like. I start that when puppies are very young, just like you do with a positive marker like "good" or "yes". It's part of the dialog, not a verbal correction like a more forceful "NO" is!
With a reactive dog I always start at a distance, as I said, and I let the dog watch other dogs or people, I don't try to distract or have them focus on me initially. I do however preempt fixation with the negative marker, then give them something else to do and praise and treat that thing. IME that's usually enough for the dog to snap out of it with that object, and we rinse and repeat that process for some time at that same distance until the marker is no longer needed before moving in a bit closer. If the subtle negative marker is not enough to snap them out of it, you're too close, move further back!
As time passes and the distance decreases, and the dog begins to better understand the desired behavior, I gradually increase the intensity of the correction - but again, this part isn't to be rushed. I prefer that the puppy/dog has ample time to think through the situation and "decide" on the correct behavior while providing subtle cues and ample encouragement!
As
@car2ner mentioned, your reaction to approaching people is as important as the dog's, because they pick up on subtle body language you may not even be aware of, and you might be unintentionally fueling your dog's excitement! This is where an experienced trainer can be extremely beneficial, helping you to "refine" your technique really quickly, saving both you and your dog weeks or even months in the process!
There is no single "right" method to train any dog any behavior, and I'm certainly not suggesting that's what this is. But I've had very good results, and it's a method that anyone can be successful with, even with little previous experience or knowledge in dog training!
Good luck!