Campfires are not allowed everywhere you want to camp.  Depending on the park, season, or even elevation you may or may not be allowed to build a fire.  There are also often county or state wide fire burns during parts of the year which also prevent you from having a fire.  Before you go out into the woods, check what the current regulations are for the area you will be in.  In pretty much all situations though, building a fire for emergency purposed, especially in winter, is usually allowed.

Forest Fire.

We should all be aware that fires are a big issue and millions of acres of land are burned every year.  Every summer we see reports of California burning, but it's not just there, they happen everywhere.  The causes can be lightening strikes and other natural causes.  They also are often caused by us.  It could be a cigarette butt flicked out of a car window, utilities failing, or intentional.  Unattended campfires though are a cause that us outdoor enthusiasts tend to be responsible for.

If you are allowed to have a fire, ideally you should have it in an established fire ring or pit.  These sites a cleared of all burnable materials, lined with non-flammable materials, and ringed by rocks or similar.  All of this is so that the fire stays in the pit.  If you don't have a pit, you will need to make a safe space for you to burn a fire.  One of the more effective methods of doing this is by use of a mound fire. Basically, you're going to dig up non-flammable dirt and put it on top of a tarp or something similar.  You build the fire on top of the dirt, keeping it small, and when done you scatter your coals,  ashes, and leftover wood around, then replace the dirt where you found it and make it look like you were never there.

small campfire in improvised ring.

What should you be burning?  Unless you are at a place where you can buy or easily haul in your own wood (note, the emerald ash borer is a big issue, so many places have limits on how far you can transport wood), you're going to be gathering wood.  The general rule of thumb while doing this are the 4 Ds.  Downed wood, Dead wood, Dinky (small) wood, and Distant wood.  You should not need any tools to build the fire, everything should be able to be broken by hand.  Anything that is standing, even if it is obviously dead, should be left standing.  Live wood doesn't burn well, so you don't want to go cutting it down.  Finally, you want to go out and limit your impact while gathering wood.  Go in all directions, and go far from camp, taking only some of the wood you find.

When you are done with your fire, you need to make sure it is completely out.  It is possible to have some hot coals buried in your fire pit that are not visible.  All it takes is a good wind on the pit for them to come back to life.  The best thing to do is to drench it with water until you are able to run your hands through the coals.  If you're not at an established fire pit, you will then want to distribute any coals and left over wood.  Generally speaking, you are going to want to scatter them as far as you can throw them.  Don't do it in one spot, but spread them out all around, and as far from the camp site as you can.

As I mentioned at the top, there are places where fires are not allowed, and there are good reasons for this.  One example is the Central High Peaks region of the Adirondacks in NY.  Back when I first started hiking in the region in the early 1990s, you could stand on Marcy Dam and see every single camp site.  This is a major camping spot in the region, and what had happened is everyone camping there was burning the undergrowth.  Anything small that could be burnt was gathered and burnt.  In 1999 new regulations went into effect banning fires.  You now have to bring in a stove to cook.  It took a few years to have an effect, but if you were to visit there now and stand on the remnants of the dam, you cannot see any signs of the campsites.  One small change to the regulations has made an immense change to the environment.