Digging the Pit: The size of the hole in the ground you need is determined by what you are going to cook. The pit needs to be about one foot larger in every direction. If you have a pig that is four by two feet roughly then you need a hole six by four feet. The hole should be about three feet deep. The size of the hole is going to determine the size of the fire and how much of everything else you are going to need, so you need the hole first.
Lining the Pit: Most pits are lined in stones of bricks. This is done to even out and hold in the heat. Large stones, about the size of your head are perfect. One rule though is to avoid stones that have been in salt water (like the ocean) in geologic time (say the past few million years). These stones have a tendency to crack, break, and sometimes down right explode. If you plan on doing this a lot lining the pit with bricks is a good idea.
Building the Fire: You are going to need a lot of hot coals to do your pit cooking. Traditionally you would fill the pit with logs and burn them down to coals. This process can take the better part of a day. Some people choose charcoal but you are going to need a lot and since the fire isn't going to produce much smoke to flavor the meat you can go with the cheapest solution. What you are going to aim for is about a foot deep of burning hot coals before you start the actual cooking.
Wrapping the Meat: Whatever it is you choose to cook needs to first be flavored and then wrapped. Some people will say that if you are doing a large animal you should place hot rocks in the body cavity. It's up to you, but I haven't found it necessary. What you do need is a secure package to put in the fire. This means tying up the meat firmly. Some people use chicken wire to wrap it together. This makes a good tight package. In the old days an important part of this wrapping was banana leaves (or other large leaves). This provided protection from the fire and moisture to the meat. These days' burlap bags are used to make a damp surface and aluminum foil is used to separate the meat from the coals. You use what you can get.
The basic wrapping instructions are to take the seasoned and prepared meat. Wrap tightly in many layers of foil then wrap that in lots of wet burlap. Finally you want to wrap that in a heavy wire frame. This holds the whole thing together and gives you something to hold on to. Once you have it wrapped tightly you are ready for the fire. One tip, if you are doing a whole hog you need the mouth propped open to let heat through. This is why the apple was put in the pig’s mouth.
Loading the Pit: With the help of several strong people and possibly a few 2 x 4’s you can now lower the meat into the pit. As soon as the meat is in the pit you need to cover it up. This keeps the burlap from burning by starving the fire of oxygen. The coals will remain hot for days, but you won't have an actual fire anymore. This can be done by covering the pit in dirt, but then you'll have to dig it all out later. You can use a large sheet of metal, but what you need to do is cut off the air from getting into the pit. Otherwise the burlap and then the meat will burn. By covering the pit you maintain a constant temperature that is perfect for cooking.
Cooking Time: This is going to take a while. If you have a very large hog with loads of vegetables (yes you can add these in to the pit too using the same method) you could be looking at the better part of two days. Generally though, the cooking time is going to be around 12 hours. The size of the pit dictated the size of the fire and therefore the amount of heat in the pit. This controls the cooking time. If you built the right size fire you should have about the same amount of time, no matter how much meat you have in the pit. Traditionally the meat goes in the fire at night for eating the next day. Since the meat is tightly wrapped it won't dry out and can tolerate a little overcooking so you have a large window to work with.