In reply to alastairmac: The OP doesn't mention whether the question relates to sport or trad, most of the above posts have assumed a sport situation. The way i do it depends on each situation. Looking at sport first, i normally face the carabiner gate away from the bolt, on occasion due to the bolt placement or rock shape I may face the gate towards the bolt if there is a greater risk of something elsepotentially opening the gate either in the process of normal climbing or a fall. The carabiner clipped to the rope is considered next the gate should face away from the direction of climbing, ie the rope runs over the back bar and is not back clipped.
In a trad situation again it varies or depends on each placement. First I consider the carabiner clipped to the gear, place it in the direction in which the gate least likely to open. Then consider the carabiner clipped to the rope, again gate away from direction of climb, in rare situations if this means a risk of the gate opening I may turn it around, (asking myself is the greater risk of opening due to the gate catching on something or the rope unclipping in a fall). On a long extender or not knowing the direction of the route I may clip the "rope" carabiner either way around.
So how do I rack them - I tend to have a mix, but however I have the racked i normally end up rearranging the orientation on some draws as I use them depending on the placement.