There are 4 key factors in defending nukes with terran. They are:
If your expecting your oppenent to nuke rush then your best bet for early defense is turrets, spider mines, and if possible comsat. Place Turrets everywhere in random locations this makes it very difficult if not impossible for a ghost to stay concealed in your base, also place a few outside your base like close to cliffs and stuff.
For spider mines the best places to put them are where you expect them to nuke you from, like up from a cliff or from a valley at the side of your base.
Comsat is basically self explanitory but i'll give you hints just in case no one knows what to do with it..... Suppose your defense is about to get nuked (a terran wall, 3 tanks, and a turret) you see the little laser dot on one of the depots, you will comsat a good distance away cuz he may be using ocular implants and + comsat has a good revealing radius.
Science Vessels come in handy later in game but they're quite basically useless if they use medics and blind it. They only good thing they have going for them (if upgraded) is to use EMP and Irraidate on the ghost/medics. EMP will disable ghosts cloak and medics healing/blinding. Irrate will most likely kill the ghost and the medics so that may b your best bet (however this sometimes may not work) so unless you have no units nearby use irrate. if u do and they blind ur science vessel just use emp to find him.