There are several simple rules that you need to follow in building a campfire.
Never build a campfire on forest liter or duff, this is plant debris such as pine needles and other decomposing plant remains on the forest floor. Look for a site that is at least fifteen feet away from tent walls, shrubs, trees or other flammable objects. Beware of low-hanging branches overhead.
Clear the ground of all flammable materials from an area at least 5 to 10 feet. Scrape right down until you have bare earth. Dig a shallow pit and start the fire in the pit.
If possible, build a ring of rocks around your fire. This will help to contain the ashes and prevent the spread of the fire.
Keep campfires small, you don’t need a bonfire.
If it is a very windy day, take in to consideration the possibility of sparks or hot embers being blown into flammable materials. You may need to find a sheltered area or forgo a fire,
Never leave your fire unattended.
If possible, have a shovel and extra water readily available.
Before you leave make sure the fire is dead. Stir the ashes to bring hot spots to the surface. Douse the fire with water if possible. Urinate on the fire if necessary. If no water is available, cover the fire with a thick layer of dirt.
The above is based on hot dry condition, if it is raining or snowing and cold you may be able to modify these safety rules to some degree. But remember if you start a fire by accident under TEOTWAWKI conditions, you can easily become a victim of that fire, losing either your equipment or your life.