Lima suffers from opportunistic crime. While you are unlikely to get physically hurt, travelers do regularly have their belongings stolen and muggings can happen. The basic precaution is to look as little like an affluent traveler as possible: don't wear expensive watches or jewelry; use a small pocket-sized camera; carry your money as loose pocket change; move around confidently; and don't use a map unless seated at a cafe or restaurant: it's a dead giveaway.
Central Lima and the area around the bus terminals have many pickpockets, but even ritzy Miraflores has opportunist thieves. Take extra care on the beaches with your belongings, and look out for gangs of youths playing soccer - they've been known to mug hapless lone travelers. Use taxis to get around at night, and generally adapt a streetwise attitude to keep out of potential strife.