I leave the town.
Staying inside the town means that you have to be rather familiar with smells sounds and general zombie behavior in order to pick a safe spot that conceals you, and be good enough at combat to kill any zombie that does try, and never, ever, ever step outside in the town during the daytime unless you have road runner and some adderall or other powerful stimulant. Chances are if one zombie finds your hideout within the boundaries of a town it’ll attract the rest by bashing the door down. A row of pits is helpful, but has this tendency to only stop me from digging when a Hulk punches me in the face, and that is a sketchy situation to be in.
Go out of the town after 9:30 AM - bring a knife of some kind to butcher with, and you can kill woodland creatures for food. Rocks can be thrown repeatedly to keep smaller packs of wolves at bay while they try to surround you and eventually kill them, and Cougars that usually travel alone are also vulnerable to unskilled rock barrages. Carry like 4 rocks and keep picking them back up as you throw, until you find a good melee weapon like a machete or a baseball bat.
Sewage treatment plants, houses in the forest ( they spawn there regularly) and several other locations outside of town make excellent places to camp out in relative safety (usually, watch out for anything that seems fungus-y.)
The first day from the time you escape the town to the time night falls, read books, eat food, build up some experience, and then that night go into town with an empty inventory, all your clothing from the first morning, and start stocking up on things you think you’ll need. You may want a vehicle and some jerry-cans to fill with water if you’re living far from a toilet or other water source.