One of the first step to get a visa, is to go to the mexican consulate close to your home and get it. You have you have to make an appointment and talk to the officer and tell him why you want to have a resident visa.
Once you get the visa, the next step, It{s to enter Mexico and go to the immigration office in order to exchange the visa stamp in your passport for a residentent card.