Summarize this article:

Use a Phillips head screwdriver to unfasten the two or three screws located on the inside knob plate. Then remove each side’s door knob by pulling them away from the door. You may also need to use a wire tool or a paper clip. If your knob or lock has no screws on it, insert a paperclip into the small hole on the side of the doorknob. This should release the knob latch and will allow you to pull off the knob. After removing the knobs, measure the diameter of the lock’s hole and the distance from its center to the edge of the door. Check your current lock’s brand, and purchase a lock that matches it and fits the hole’s dimensions.  You can find a new lock that meets the measurements you took at a home improvement store, locksmith, or online. If you buy the same brand, your new lock will match your other locks, and you will most likely be able to install it using the existing holes. The latch is the final piece of lock equipment you need to remove. Unfasten the two screws that hold the latch plate in place. Once the screws are out, you can slide out the latch from the opening in the side of the door. A store-bought lock will come with a cardboard template that shows you exactly how the lock will fit onto the door. Place this template over the hole in your door and make sure that everything matches up. If the template does not match up exactly with your hole, then you bought the wrong lock. If you bought the wrong lock, take the old lock that you removed back to the hardware store and ask for help finding a lock that fits your needs. If your template checks out, begin installation by sliding the new latch into the opening on the edge of the door. Drive the new screws through the holes in the latch plate and into the door edge to secure the latch. It’s best not to reuse your old screws, since they might be old and weaker than new screws. If your new lock didn't come with screws, buy ones that fit the lock and match the color of your hardware. Place the outside knob (the one with the keyhole) and the inside knob on their respective sides, then slide them through the lock hole toward each other. They should meet in the middle and connect. Don’t force them together, but allow them to slide together easily. Drive screws into the holes on the inside door knob plate to finish putting the lock back together.

Summary:
Remove the screws from the old lock on the inside of the door. Use a lock of the same brand that fits your door. Remove the screws that secure the latch at the edge of the door. Wrap the cardboard template around the door edge. Put the new latch into place. Put the door lock together.