Contact the Oficina de Migraciónes for visa issues or to apply for residency. Tourists can stay in Peru for 183 days. If you plan to stay the full period, speak up when you get your entry stamp to get the maximum allotted time, otherwise you might be granted 30 or 90 days.
Keep the tourist card you receive upon entry into Peru in your passport for your entire stay, you will need it upon exiting the country. If you lose it, it's possible to receive a copy online.
Peru no longer allows extensions to tourist cards. Readers have remarked that travelers have been able to make on-site payments for varied fees with certain flexible officials, this risky behavior is not condoned by Lonely Planet.