Measure the door opening of the closet using a tape measure.
Mark two of the two-by-fours the length of the door opening and cut them off squarely on your marks using a circular saw.
Lay one of the two-by-fours on top of the other one with the wide sides together. Ensure that the ends are even and insert two 2-inch drywall screws about every 6 to 8 inches along the length of the boards. Use an electric drill with a driver bit installed to drive the screws into the boards.
Hold the header that you just constructed up to the door opening and measure from the bottom of each end to the floor. These measurements are the lengths of the jacks needed on each end to provide support. This is accomplished more easily if you have someone help you.
Cut the remaining 2 two-by-fours the lengths from the previous step using the circular saw.
Attach the jack studs to each side of the door opening using the electric drill and 2-inch drywall screws. Lay the header on top of the jack studs and secure it with two screws on each end with the electric drill.