I concur with swechsler and add the following. Ther distance from a wall with a rear vented enclosure should be at least equal to the diameter of the vent. I feel it safe to assume this would be the same with two vents. Ergo, 3" for either a single vent of 3" diameter or two such vents.
Using that same logic, it would seem that for a rear passive radiator, the distance should be equal to the effective piston diameter of the passive radiator. This would be 6 3/8, 8 3/8, 10 1/2 and 12 5/8, 15 (inches) for 8", 10", 12", 15" and 18" radiators, respectively.
For a sealed cabinet, "theoretically" max bass output would be with the enclosure against the wall. This does not mean it will sound better, Many sealed enclosures have been placed a couple of feet from any wall.
It's very subjective but regarding the vents or passive radiators, no obstruction should be present as per the above.