A YouTube subscriber asked me the following question: "How long did it take you to get to the skill level where you could say that you can, without shame, perform in front of an audience?"
The question made me stop and think. There is no easy answer. It takes time and experience to become confident playing in public. You must realize that performing doesn't just happen. Playing in front of people needs to be practiced about as much as you practice the guitar in order for it to become second nature. Playing to others should be part and parcel of learning any musical instrument. It is the main reason to learn musical instruments and yet something that has been lost over time as people these days listen to recordings more than live performances.
Being on stage can suddenly and frighteningly feel so much different from practicing in your practice studio or bedroom. All eyes and ears are focused on you expecting to witness not only perfection but a meaningful and perhaps memorable performance. One of my university colleagues once recommended that when practicing at home you should try to imagine that you are on stage in front of a large audience, and when in a performance situation imagine being back home in your practice room. The theory being that if you treat your practice time as seriously as you would a public performance, it should be less scary when the time comes to be on stage.
Most importantly you should never publicly present anything that is beyond your capabilities, that you can't play perfectly and convincingly at home. It takes experience and confidence to perform perfectly music that you have only just started to play a week or so before. Choose the piece or pieces that you know inside out and can play with confidence. Be honest about it. Are you being too ambitious or trying to play a piece that you cannot technically cope with? Then choose something that's easier and remember that the simpler pieces can be just as effective and touch people more powerfully than technically difficult ones.
If you can, seek advice and feedback from others, particularly anyone with a good knowledge of music. Sometimes your family and friends are not the best judge unless they are musicians. If you can't find a guitar teacher, try someone who teaches other instruments or singing. They probably won't be able to show you how to play the guitar but they will have the knowledge to advise you about your approach to the music and how you might improve it.
Do your best and accept that sometimes things don't go well in a performance and be prepared to get up, try again another time. Mistakes happen and you might feel depressed about them but they can help you grow stronger as a player.
If you have an important performance coming up, say in a month or so's time, it's a good idea beforehand to practice performing in safe situations, e.g. play to one person you know well, then perhaps two or three friends, and after that try playing to a small group of people you know. One of my teachers used to joke that you must always play to your cat first, then move on to people!
If you can't find anyone to listen, your next best option is to use a recording device to record yourself playing. Most people find it more difficult to play well when being recorded than when playing to an audience. Listen to your recordings too. You might hear some aspects that could be improved on. Try again until you are completely happy with the recording.
Joining music groups, e.g. guitar duo, quartet and mandolin and guitar orchestra all helped my confidence in performing. The more you do the easier it becomes. For me, perhaps it took ten years to become confident. I'm not sure. My first performance was in front of a huge assembly of school children when I was aged 11 - before nervousness became a problem. At university you are expected to perform if you want to or not, for me equating to four years of being tested.
Last but not least, if you think you have attained a level of confidence in performing, it can fade unless you keep putting yourself in performance situations. This is a problem that many fine classical guitarists struggle with as performance opportunities can be difficult to find. It is often a case of making your own opportunities, in doing so becoming not only a guitarist but also a concert organiser!