Popularity is when other people like you. Happiness is when you like yourself.
How do we get to like ourselves and not fall prey to always seeking acceptance from others? The key is to know your values. Your values are what kind of person you want to be. For example, I value respect, kindness, giving, and learning.
If you're not sure what your values are, then imagine it's your funeral. What do you want people to say about you?
When you are clear on your values, then you can live by them. When you live by your values, you are happy with yourself. Furthermore, you can choose to only seek acceptance from people whose values align with yours.