The best way to learn how to swim is in-person with a certified instructor. Check the pool facilities in your area for your swimming instruction options. If you need the most basic level of swimming lessons, but can only find children's classes, then you may want to work privately with an instructor. If you feel fearful of the water, make sure you choose an instructor who is sensitive to this and do your best to practice swimming strokes and kicks as much as possible.
If you feel that you need time to get used to the water before taking classes to learn how to swim, some aqua aerobics sessions in the shallow end of the pool may be a good idea. During shallow water aerobics, your head and shoulders are always above water, while the rest of you is submerged. Taking water aerobics classes before learning to swim can make you more comfortable in the pool. You could also go to public swim sessions and hang onto the side of the pool while facing it on your stomach with your feet out to practice kicking.
To learn how to swim, your instructor will have to ensure that you are able to float, hold your head under water and drown proof. Drown proofing means being able to remain upright with your head on the surface while treading water in a deep area where your feet can't touch the bottom. Leg and arm movements help keep you afloat. You can practice holding onto hand buoys before drown proofing without them. Before learning swimming techniques, starting with the basic front crawl in which your head will alternatively be under and above the water, it's a good idea to practice submerging your whole body under water while holding your breath.
If you aren't able to lay flat on the water to float, a swimming instructor can hold your legs and back while you practice. While you won't need to have mastered floating when you learn how to swim the front crawl, which is the most common swimming stroke, you will need to for the backstroke. If you learn the crawl and backstroke, these strokes will allow you to do basic swimming and have the foundation to learn other swim techniques. Make sure your instructor teaches you proper hand and leg movements with the strokes.
As you learn each new swimming technique and stroke, remember to keep going and don't get discouraged if it seems to take longer to master swim classes than you'd hoped. The most important thing is that you try your best and keep practicing what you've learned. Once you learn how to swim, go to public swimming sessions regularly so you can practice. When you're ready to swim many laps in a row, look for public swimming pools in your area that rope off lap lanes.