People don't give a second thought about a door until it come off its hinges, it refuses to stay closed or it refuses to open. Whatever the problem, it can help to know the basics of hanging a door, whether you're repairing one or installing a new door to hang.
The door as most refer to is actually the combination of many parts. A door is comprised of about five different components including the slab, the jam, the door stop, the hardware and the casing. So when these parts are put together, minus the casing, this is called a pre-hung door.
The first step to installing one of these is to line up the hinge side of the jam to the framing using shims. Ensure that you are using a level to make sure that the jam is plumb. Nail the jam to the framing with no more than two nails per area where the shims are installed to help the door hang loosely in place. Once that side is done, work your way around the top of the door to the handle side. When it's loosely in place, use more shims to level the jam to create your reveal. The reveal is the gap between the slab and the jam of the door. There should be about an even 1/8 to 3/16 of an inch reveal all around the top and sides of the door.
When the reveal is even, the next step is to make sure the slab fits tightly to the door stop. This door stop is already fixed to the jam. If there is no positive connection to the door stop, for example, the slab touches the door stop at the top but there's a gap at the bottom, the door won't latch once the hardware is installed. This can also happen if the reveal is off, sagging and unaligned. This next step is to make sure everything is level and even because once nailed into place it is difficult to make adjustments.
Using nails or screws to permanently affix the door in place is the next step. Once this is done, the casing can be installed. The final step is to install the hardware. If these steps are done correctly, your door should work like new and withstand years of opening and closing.