That depends on your latitude, altitude, and the season. The type of UV that most effectively produces vitamin D (UVB @ 296 nm) cannot penetrate the amount of atmosphere between you and the sun if it is too low in the sky.
And natural synthesis reaches an equilibrium after about 15 minutes of exposure.
So for many, the most efficient way is swallowing a 10000 IU capsule 1 to 7 times per week.