How your turrets are positioned in your base is crucial to a successful defense. There are two main principles to make the best turret placement:
When it comes to spacing out turrets, the two goals are a bit in conflict with each other. To achieve #1, the best way would be to clump all your turrets together. But then they become vulnerable to titan, deathstorm, orbital strikes and haywire. They also fall quicker to splash damage weapons (e.g. jetbikes).
So there is a balance between keeping your turrets tightly packed and spread out. Some considerations when trying to find this balance:
One principle to keep in mind is that killing enemy units earlier is always better than killing them later. The sooner you can kill some units, the less units they have, which slows down the destruction of your base, giving your turrets more time to further do damage.
To maximize the damage you do right at the start, position your turrets so that the enemy comes into range at the same time as they can start firing on your buildings. So put shorter range turrets like bolters/flamers near the front and longer range turrets like whirlwinds/beamers at the back.
I call the area just outside the base perimeter "The death zone". You want many of your turrets in range of the death zone. This is especially true of turrets that do splash damage or area damage (beamers, whirlwinds, plasma, graviton, etc.). That's because units tend to stop or slow down once they enter the death zone (as they start attacking your buildings). Lining up your tanglefoots to land on the death zone will further slow down infantry units.
You also want to consider the type of unit you are trying to kill. Beamers/gravitons are your best defense against glaives. But glaives also have a long range. So ensure your beamers/gravitons can hit the glaives even when they are a ways off from your base.
In addition to the front of your base, you need to defend the middle of your base and near your HQ. These are popular spots for Horus/Ezekyle to teleport in. Since Horus/Ezekyle are usually accompanied with high-dps units like support or bikes, make sure you have a few bolters and flamers near your HQ and near the middle of your base. Ideally most/all of your turrets can reach your HQ.
Also deploy at least a few turrets behind your HQ. If not beaconed, units will get distracted attacking the HQ before all turrets have been destroyed.