The enemy outside the walls
Walls
You will obviously need walls. Castles had them, prisons and other modern buildings have them. Fortifying a small town is not an easy task as manpower, building materials and knowledge are required. It could still be done as it has been done many times in the past. But for that to be possible one would have to have a large group working for extended periods of time with part of the group actively protecting the rest of the group. The best option is always to re-purpose some existing structure.Zombie traps
Traps could be an important asset for the protection a community. By using simple sound and light producing devices, zombies can be attracted away from the village and caught in ditches or tricked into falling from a height sufficient to kill them in a more definitive fashion. If you use traps be sure to clean them at regular intervals otherwise they may get to a point where you cannot control them any more.Topography
If possible use the topography to channel the zombies away from your living area. It is reasonable to think, although not necessarily true, that zombies will follow the path of least resistance, unless there is a stimulus that would make it act in a different way. For instance, it is reasonable to assume that zombies would not voluntarily climb a steep incline.Sound barriers
Zombies are attracted to sound. It is expected that a community will produce sound and reducing that sound as much as possible would probably be a good investment. Part of that will have to come from the adoption of a certain discipline towards noise making. A garage band is probably not a good idea. But you could also achieve good results through some good old engineering. Highways have sound barriers and anyone would hardly fault you if you were to remove and use them for such a meritorious purpose. You would need help and a big truck, though.Other enemies
Zombies will not be your only concern. Other people, gangs, or communities may represent a threat to your settlement. You may face open attacks or insidious infiltrations. Plan for each of these occurrences. Create mechanisms to vet unknown people coming in, create defensive plans, a defense force, defensive weapons. Stock up in ammunition, store food and supplies, identify water sources. Nothing new under the sun there.
The enemy within
Politics
Once you establish a community, you go back to the same old problems society has always faced. In this case, given that you would be living under the equivalent of a non-declared state of war, the stakes are higher and so will the risk be. The more you are able to recreate the mechanisms of a stable society the less risk you run of being stabbed in the back. However, this is not something which is easy to establish in a small community always at constant risk of attack or of running out of supplies. Executive, judicial and legislative bodies of government are not the easiest thing to setup. For a fairly small community you can probably get away with some sort of referend-based democracy. This may work for occasional decisions, but for under-stress situations doesn't work so well, There will need to be a leader and some sort of hierarchy.
If you are the leader of a community, other people will be after your job. Were you elected or naturally ascended to that position? Was it out of fear or of respect for your decisions? Are you running a tight, cohesive community, or are new members constantly joining? Above a certain rotation of community members, the cohesion will be low. This means that new elements will not necessarily recognize your value to the community or your leadership. New members may even be infiltrating your community in order to destroy or weaken it. Maybe to create the conditions for its subjugation or merger with another community. The best chance you have of keeping your community will be to prove to be a valuable leader. But are you a good leader? Do you have what it takes? Would you be providing a better service by taking some other role?
Whatever the situation will be, as in all circumstances where a group of people need to work together, there are politics involved. That will not change with a zombiepocalypse.