Framing a wall is fairly simple. A wall, after all, consists mainly of vertically running boards -- typically two-by-fours -- called studs. At top and bottom, two boards run horizontally, capping the studs -- similar to how rails attach to the rungs if you turned a ladder sideways. Framing any opening is slightly different. For a door, you must not only build the opening properly, but you must leave enough width to properly hang the door when you're finished.
It's usually best to start with the door, then frame the opening according to the door width. The reason for this is that most doors come in standard sizes, and without knowing the size, it's next to impossible to plan for the width you need. You can also order custom doors in any size you want, but such doors tend to cost significantly more. If you're working with a wall that limits your door width, select the door you desire with the wall length in mind. You must have a minimum of 3 inches for the framing on each side of the door. More is better, as it keeps the wall from looking like nothing more than a door and trim.
Framing New Walls
Once you have a door selected -- or at least know the door size you will use -- you'll likely need to frame the entire wall. First, cut two plates to the wall length needed. Mark the plates every 16 inches with the exception of the door location. Start at one end, making a straight line to indicate the middle of the first stud, and additional marks thereafter until you are close to the edge of the door. Move to the opposite end of the plates and repeat until you run out of room near the door. Next, measure the distance from the ceiling to floor in the wall location. Subtract 3 1/2 inches -- enough to account for the thickness of both plates and a little extra for clearance -- then cut one stud for ever mark and two for the very ends. Nail between the plates accordingly, centering the stud over the marks and driving nails through the plates into the end of the stud involved.
If you're cutting an opening in an existing nonstructural wall, you may not need to frame the wall, but you will have to cut the sheathing away to allow for the doorway. Extend the removal to the closest stud past the door location, as marked on the wall beforehand, and slice away the drywall or paneling from floor to ceiling. Work carefully to avoid cutting into any framing or other items running through the wall, if present. Wires, plumbing or ductwork that you encounter can generally be pushed out of the way or above the doorway as you frame it. Consult a professional for assistance as needed.
Rough Opening Size
Most prehung doors -- the door style recommended for the average DIY installer -- will specify the exact rough opening size needed. Otherwise, to ensure a properly fitting frame, add 2 inches to the door width and 2 1/2 inches to its height. This is the size of the necessary rough opening -- sometimes signified with the abbreviation "RO." The extra space allows for room to shim and adjust the door to ensure it's level and square, plus the framing doesn't actually rest on the door this way.
Framing the Doorway
Measure and mark the door rough opening width on the plates in between the last studs installed. Some builders prefer to build the doorway first, in fact, and then frame the rest of the wall. Next, add 3 inches and mark the plate again on the outside of the rough opening, working toward the plate ends. Cut a king stud to the same height as the full-length studs and nail between the plates just inside this final line. Make two jack studs equal to the height of the door rough opening. Push against the king studs and nail in place. Another board, measuring the width of the opening from king stud to king stud, creates the door header. Finally, cut short lengths of wood to run between the header and top plate to spread the weight of the opening across the width. Always check to ensure the width from the inside of one jack stud to the opposite equals your rough opening required.