I have a city in space that will have a local population and a lot of travel in and out (center of commerce). Should I place it out in open space or near a planet?

Being near a planet obviously involves gravitational forces that affect both the station and travel; my gut feeling is that that's a positive thing but I'm not strong on the relevant science. It also seems like placement near a *suitable* planet would provide resources the inhabitants might need -- food, water, raw materials.

If it should be situated near a planet, what is the best positioning? Should it be in line with a pole, in the direct line that runs from star to planet, something else? How far out should it be, with respect to the planet's gravitational influence? (I assume it has to at least be as far out as a Lagrange point or it'd fall to the planet, but they're sometimes depicted as seeming much farther out.)

Does the placement decision interact with the [shape of the station](https://worldbuilding.stackexchange.com/q/4444/28), or are these orthogonal decisions? How does the mass of the station affect things? What other factors do I need to take into account?