Safely Meet and Greet a Dog out on the Street

How to greet a dog on the street in a proper way so you are not bitten.