Avoid people who have infections that sometimes lead to pneumonia. Stay away from people who have colds, the flu, or other respiratory tract infections. Wash your hands often in warm, soapy water. Use an alcohol-based hand sanitizer when you can't wash your hands. Avoid exposure to people who are ill whenever possible. Get enough rest. Eat a healthy diet that includes lots of fruits, vegetables, fiber, and lean protein.