As stated above, you need to be ok with yourself first. By that I mean generally. We all have flaws and we all have things we need to work on, but you should be generally comfortable in your own skin. If there are things about yourself you do not like, work on them.
Next, be comfortable doing things alone. I big confidence boost for me came when I started going to movies and restaurants by myself. Society has this unspoken rule that you HAVE to do things with someone else and it is just plain untrue. I had a "date night" with myself and it was amazing.
Third, as others have said, get hobbies. Find a way to entertain yourself while no one else is there. This can also help with the two above points. You might also find someone else who shares a hobby interest and start a friendship there.