In order for a door to open and close without rubbing, you must fit the door frame correctly. Improperly fit frames have uneven gaps around the door when closed. In the worst cases, the door will hit the frame and will not even close. The door trim's pieces meet flush, without any gaps, when the door frame fits correctly in the wall's rough opening. Properly fit door frames allow the door to close tightly and seal out drafts.
Measure the height and width of the outside of the door frame and the inside of the door's rough opening, the space in the wall where the door goes, with a tape measure. Compare the two measurements. The rough opening should measure at least 1 inch larger in both directions.
Place a bubble level on the floor at the door's rough opening. Check that the floor is level. If the floor on the hinge side of the opening sits lower than on the latch side, then place shims under the low end of the bubble level until it reads level. Nail the shims in place with a hammer and an 8d finishing nail.
Slide the door frame into the rough opening. Keep the bottom of the hinge side on the shims. Push the finish side of the frame against the drywall.
Hold the bubble level against the hinge side of the frame. Adjust this side of the frame until it fits plumb, when the level's bubble centres in its housing, in the rough opening. Slide shims between the hinge side of the frame and the rough opening. Tack the hinge side in place with 8d finish nails.
Hold the bubble level on the top of the door frame. Adjust the door frame's top until it fits level. Place shims between the top of the frame and the bottom of the rough opening's top. Tack the door frame's top in place with 8d finish nails.
Hold the bubble level on the latch side of the door frame. Adjust this side until it sits plumb. Slide shims between the frame and the rough opening and tack it in place with 8d finish nails.
Double-check that both sides and the top of the door frame are plumb and level. If the frame requires adjustment, then start at the hinge side and work around the top to the latch side.
Secure the door frame to the rough opening with 8d finish nails. Drive a nail 4 inches from each corner and every 16 inches in between.